I used streamreader to read csv and it works locally but when I put it on web host (GoDaddy) it fails with error message below:
Could not find file 'C:"usersdesktop"\comma.csv'.
Line 38: StreamReader sr = new StreamReader(path+mainDataFile);
I was trying to get my webpage to find users desktop automatically, then grab the file called comma.csv. without uploading anything.
path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); mainDataFile = @"\comma.csv"; StreamReader sr =
newStreamReader(path+mainDataFile);
From when I'm reading on the web, internet security does not allow a webpage to allow access locally to a users pc. There has got to be some way to find the file on the users desktop. What do you think?
This is server code and only runs on the server. As you've found out, due to security restrictions, you cannot access the users machine. Getting the users to upload a file is your only option.
Marked as answer by solarissf on Apr 10, 2012 12:41 PM
I read something about the user downloading something granting access, then the website can access the users local files. Do you know anything about this option?
Sorry no, I don't know anything about that. It would have to be an ActiveX control or Flash component I'd think, but even then I'm not sure how it would break out of the browser sandbox.
solarissf
0 Points
60 Posts
Problem with StreamReader sr = new StreamReader(path+mainDataFile); Cannot find file
Apr 09, 2012 01:40 PM|LINK
I used streamreader to read csv and it works locally but when I put it on web host (GoDaddy) it fails with error message below:
Could not find file 'C:"usersdesktop"\comma.csv'.
Line 38: StreamReader sr = new StreamReader(path+mainDataFile);
I was trying to get my webpage to find users desktop automatically, then grab the file called comma.csv. without uploading anything.
path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
mainDataFile = @"\comma.csv";
StreamReader sr = new StreamReader(path+mainDataFile);
From when I'm reading on the web, internet security does not allow a webpage to allow access locally to a users pc. There has got to be some way to find the file on the users desktop. What do you think?
Dave Sussman
All-Star
37716 Points
5005 Posts
ASPInsiders
MVP
Re: Problem with StreamReader sr = new StreamReader(path+mainDataFile); Cannot find file
Apr 10, 2012 08:15 AM|LINK
This is server code and only runs on the server. As you've found out, due to security restrictions, you cannot access the users machine. Getting the users to upload a file is your only option.
solarissf
0 Points
60 Posts
Re: Problem with StreamReader sr = new StreamReader(path+mainDataFile); Cannot find file
Apr 10, 2012 11:49 AM|LINK
Thanks Dave,
I read something about the user downloading something granting access, then the website can access the users local files. Do you know anything about this option?
Dave Sussman
All-Star
37716 Points
5005 Posts
ASPInsiders
MVP
Re: Problem with StreamReader sr = new StreamReader(path+mainDataFile); Cannot find file
Apr 10, 2012 12:37 PM|LINK
Sorry no, I don't know anything about that. It would have to be an ActiveX control or Flash component I'd think, but even then I'm not sure how it would break out of the browser sandbox.
solarissf
0 Points
60 Posts
Re: Problem with StreamReader sr = new StreamReader(path+mainDataFile); Cannot find file
Apr 10, 2012 12:41 PM|LINK
thank you, appreciate the help