开发者

Using FileUpload C#

I have a project where I get a list of file location strings that I want to save locally. I want to use a FileUploader to do so. I am trying something like this so far:

            FileUpload filesaver = new FileUpload();

            //Iterate over each files (InputFiles is a linked list of file locations)
            foreach (string File in InputFiles)
            {
                //Get file
                Stream fileLoaded = OpenFile(File);

                filesaver.FileContent = fileLoaded;

                //Save file                    
                filesaver.SaveAs(DownloadLocation);

                //Code...}

The problem is 开发者_StackOverflow中文版that filesaver.FileContent = fileLoaded; is not a valid call (FileContent is read only).

How would I be able to get the file to the file loader so that I can save it if I have a string of that file location?

Edit I am using the FileUpload Class


The ASP.NET FileUploader has the client side send the file to the server side. It does not send a file path as a string, so there is no way to intercept the file path and "upload" on the server side. if that is your intent, you are not going to find a way to get there from here.

If you want to save the actual file binary bits once it gets to the server, there are plenty of examples out there that persist the data to databases or file system.

If you are trying to get paths as strings, the file uploader is not your best choice, but note that the file path strings, if they are local to the client, are of no use on the server side.


You can just use:

If (filesaver.HasFile)
{
        filesaver.SaveAs("C:\YourFilePath\" & filesaver.FileName);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜