filestream 'could nor find a part of the path'
filestream 'could nor find a part of the path'
(OP)
I searched all afternoon - found lots of post here and there ... but error still here ...
I am trying to open a file (to store it in a database).
The error occurs here
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
If I run it on my machine (local), and try
to open a file
* c:\Project\MyFile.pdf
=> it works fine
* C:\Users\ME\Desktop\MyFile.pdf
=> access denied
If I run it from the web , I get the error
=> could nor find a part of the path
* In Web.config I have added : <identity impersonate = "true"></identity>
* Users will upload the files they want, I cannot ask them to change the files access right (I am not sure they have the rights to do it !)
* on the server, IIS V6.0 , Application Pools Identity is 'Network Services', I checked "Enable anonymous access" and "Integrated Windows authentication" on th Web Site.
* I am using Visual Studion 2008
If you need more information to help me out - just ask !!!
Thanks
I am trying to open a file (to store it in a database).
The error occurs here
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
If I run it on my machine (local), and try
to open a file
* c:\Project\MyFile.pdf
=> it works fine
* C:\Users\ME\Desktop\MyFile.pdf
=> access denied
If I run it from the web , I get the error
=> could nor find a part of the path
* In Web.config I have added : <identity impersonate = "true"></identity>
* Users will upload the files they want, I cannot ask them to change the files access right (I am not sure they have the rights to do it !)
* on the server, IIS V6.0 , Application Pools Identity is 'Network Services', I checked "Enable anonymous access" and "Integrated Windows authentication" on th Web Site.
* I am using Visual Studion 2008
If you need more information to help me out - just ask !!!
Thanks
RE: filestream 'could nor find a part of the path'
* C:\Users\ME\Desktop\MyFile.pdf
because this is on your desktop, the location is by default secure to all accounts that are not you.
You will need to make sure you have EXPLICITLY given permission to the account that your webapp is running under (app pool of the specific website/app)
RE: filestream 'could nor find a part of the path'
Are you trying to make an upload form then?
http://msdn.microsoft.com/en-us/library/aa479405.a...
ASP.NET appears to have a file upload form control. Taken from the MSDN:
CODE
RE: filestream 'could nor find a part of the path'
FileUpload fileUpload = (FileUpload)controlCell;
HttpPostedFile myFile = fileUpload.PostedFile;
int nFileLen = myFile.ContentLength;
byte[] myData = new byte[nFileLen];
myFile.InputStream.Read(myData, 0, nFileLen);
But I still doesn't understand why the previous code did not work.
( OK for the rights issue for files in 'myDocuments' - but when I run the app on the web, I get an error on any files ...)
I suppose the most important is that I managed to do what I needed to ...
Thank you for taking the time to answer me !
RE: filestream 'could nor find a part of the path'
Just remember.. while this is written like a program, ALL of the processing happens on the server end. By the time it reaches the client, it isn't anything more than an HTML page.