Cannot find a part of the path Error

  • Thread starter Thread starter Ben
  • Start date Start date
B

Ben

Hi All,
I know there have been previous posts with this topic but the issue for
most seems to be the security permissions on the shared drive. My
scenario is as follows :
I have IIS on local machine, I have code on a mapped drive in the
network.
I tried writing to a folder on the mapped drive and then also to a
folder in my C:, both give the same error "Cannot fnd a part of the
path". I gave the local folder FULL CONTROL to the user EVERYONE, still
doesnt make a difference.
My code is as follows :
try
{
FileStream File = new
FileStream(ConfigurationSettings.AppSettings["file_location"] +
System.DateTime.Now.Ticks.ToString() + ".xml", FileMode.Append,
FileAccess.Write);
System.Web.HttpContext.Current.Response.Write("Created the File
Stream");
StreamWriter sw = new StreamWriter(File);
sw.WriteLine(a.OuterXml);
sw.Close();

}


catch(Exception e)
{
Response.Write(e.Message);
Response.End();


}


Any help is greatly appreciated.
Thanks in advance,
Arthur
 
Ben,
"Cannot find a part of the path..." is not a permissions exception, its a
file path syntax exception. Unfortunately, you haven't shown us what you have
stored in

AppSettings["file_location"] - so we can only guess what you've got in there.
Peter
 
Perhaps the IIS user account doesn't have that mapped drive? Log locally
onto the machine as that user, and see for yourself!
 
Peter,
<add key="file_location" value="C:\Projects\MyProject\Xml\"/>

is the value for the file path, which i am able to browse to.
Thanks
 
Originally you said you had a mapped drive..so this is a reduced test?

And this is directory is on the server, correct?

Response.Write the full concatenated path and filename and post here

Jeff
 
I would like to make it work atleast for the non-mapped drive, the C:
drive is on my local machine, not on the server i was trying to map to.

C:/Projects/AdminReports/Xml/632937556787535301.xml

this is concatenated path+filename.
Thanks,
Ben
 
It has to be on the server. This is a web page right? The code is executing
on the IIS server!

C:\Projects... has to be on the IIS server for the code you've shown.

And it's \ not /
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top