I am trying to upload a file by file type html input.
after clicking on submit button. Response reached to ASP.NET home.aspx file
There coded following C# code..
string root = "C:\\uploaded\\";
root +=Request["fileName"];
var buffer = new byte[Request.Files[0].InputStream.Length];
Request.InputStream.Read(buffer, 0, buffer.Length);
System.IO.File.WriteAllBytes(root, buffer);
Above code is creating file on given path but file is corrupted..
How can solve this problem?
First of all always try to use System.IO.Path to play with file path. In your example use System.IO.Path.Combine to combine root and file name. This is tip and not related to your question. Talking abt your question use