Upload Files in C#.net Windows Application
I Want Upload some Files into a Website Host in C#.net Windows Application.what is a Best way To Upload file i开发者_JS百科n Windows Application?
That depends on your server. If it's yours you can make it listen to post requests and upload files through there. If it's not yours there's probably ftp installed, so you can try that.
See here for ftp uploading: http://www.vcskicks.com/csharp_ftp_upload.php and here for using http post requests: http://en.csharp-online.net/HTTP_Post
i found SVN is the best way so far, install the client on your local machine and on server. and install the server SNV on your sever.
Server: http://www.visualsvn.com/server/
Client: http://tortoisesvn.net/downloads.html
file upload in C#
HttpPostedFileBase file = this.Request.Files["Upload"];
if (file != null)
{
var fileName = file.FileName;
var fileExtension = Path.GetExtension(fileName);
filePath = fileName.Replace(fileName, emailTemplateImage.token + fileExtension);
var imagepath = Server.MapPath("/Upload/EmailTemplateImage/") + filePath;
if (!System.IO.Directory.Exists(filePath))
{
System.IO.Directory.CreateDirectory(filePath);
}
file.SaveAs(imagepath);
}
精彩评论