Access to the path '' is denied
-
Hello All, I was testing a simple program to upload files to sever , but it failed with the following error message. "Access to the path '' is denied" I am using .Net Framework 3.5 in windows 7 machine. The code i have used is given below.
private void cmdSend\_Click(object sender, System.EventArgs e) { // Check to see if file was uploaded if (filMyFile.PostedFile != null) { // Get a reference to PostedFile object HttpPostedFile myFile = filMyFile.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen > 0) { byte\[\] myData = new byte\[nFileLen\]; myFile.InputStream.Read(myData, 0, nFileLen); string strFilename = Path.GetFileName(myFile.FileName); //WriteToFile(Server.MapPath(strFilename), ref myData);//WORKING //WriteToFile(@"\\\\192.168.1.127\\Temp", ref myData);//NOT WORKING WriteToFile(@"D:\\Temp", ref myData);//NOT WORKING } } } private void WriteToFile(string strPath, ref byte\[\] Buffer) { FileStream newFile = new FileStream(strPath, FileMode.Create); newFile.Write(Buffer, 0, Buffer.Length); newFile.Close(); }
Can someone help me? Thanks in Advance... Sebastian
-
Hello All, I was testing a simple program to upload files to sever , but it failed with the following error message. "Access to the path '' is denied" I am using .Net Framework 3.5 in windows 7 machine. The code i have used is given below.
private void cmdSend\_Click(object sender, System.EventArgs e) { // Check to see if file was uploaded if (filMyFile.PostedFile != null) { // Get a reference to PostedFile object HttpPostedFile myFile = filMyFile.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen > 0) { byte\[\] myData = new byte\[nFileLen\]; myFile.InputStream.Read(myData, 0, nFileLen); string strFilename = Path.GetFileName(myFile.FileName); //WriteToFile(Server.MapPath(strFilename), ref myData);//WORKING //WriteToFile(@"\\\\192.168.1.127\\Temp", ref myData);//NOT WORKING WriteToFile(@"D:\\Temp", ref myData);//NOT WORKING } } } private void WriteToFile(string strPath, ref byte\[\] Buffer) { FileStream newFile = new FileStream(strPath, FileMode.Create); newFile.Write(Buffer, 0, Buffer.Length); newFile.Close(); }
Can someone help me? Thanks in Advance... Sebastian
Yu're being told that your application does not have the requisite permissions to the folder you are attempting to access.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
Hello All, I was testing a simple program to upload files to sever , but it failed with the following error message. "Access to the path '' is denied" I am using .Net Framework 3.5 in windows 7 machine. The code i have used is given below.
private void cmdSend\_Click(object sender, System.EventArgs e) { // Check to see if file was uploaded if (filMyFile.PostedFile != null) { // Get a reference to PostedFile object HttpPostedFile myFile = filMyFile.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen > 0) { byte\[\] myData = new byte\[nFileLen\]; myFile.InputStream.Read(myData, 0, nFileLen); string strFilename = Path.GetFileName(myFile.FileName); //WriteToFile(Server.MapPath(strFilename), ref myData);//WORKING //WriteToFile(@"\\\\192.168.1.127\\Temp", ref myData);//NOT WORKING WriteToFile(@"D:\\Temp", ref myData);//NOT WORKING } } } private void WriteToFile(string strPath, ref byte\[\] Buffer) { FileStream newFile = new FileStream(strPath, FileMode.Create); newFile.Write(Buffer, 0, Buffer.Length); newFile.Close(); }
Can someone help me? Thanks in Advance... Sebastian
You have two options. Choose an option you want 1)Windows 7 - Sharing and Permissions[^] 2)How to implement impersonation in an ASP.NET application[^]
thatraja
FREE Code Conversion VB6 ASP VB.NET C# ASP.NET C++ JAVA PHP DELPHI ColdFusion
HTML Marquee & its alternativesNobody remains a virgin, Life screws everyone :sigh: