Click here to Skip to main content
12,398,225 members (53,417 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# SQL
The bolded line of code below works when ran locally....but will not work when published to the server and ran from the web.
The error it gives is: "can't find "c:/....."
I know what it's's trying to find that path/file on the server when it needs to be looking locally.
How do I make it look locally for that file/path so it can be converted to a stream?
I'm using the .ASP fileupload button that visual studio provides.
NOTE: the word filePath below is just a I said above, I successfully load the file completely into my SQL Database when it's ran locally. I just can't make it look locally for a file when ran from the server.

FileStream fs = new FileStream(filePath,FileMode.Open, FileAccess.Read);

Thanks for any help/advice you can provide.

Posted 12-Jul-13 9:08am
joshrduncan2012 12-Jul-13 16:25pm
Is your goal for it to be able to be run from the server and look for a file that is stored on the server computer or stored on the client computer?
jhill444 12-Jul-13 16:42pm
run from the server......and look for a file that is stored on the client computer.
joshrduncan2012 12-Jul-13 16:47pm
C:\\.... probably won't work. It might be looking for a file stored on the server computer. I would recommend making "filepath" a UNC path to see if that works. (Not verified, just a suggestion).
jhill444 15-Jul-13 13:56pm
I've tried this several ways with no luck. Do you think I'm correct in thinking I'll need some sort of Java script to do this? what is the dang "upload file" button for if not this...maybe for use on a windows form? is it maybe not intended for server side execution?
Karthik J, Coimbatore 13-Jul-13 0:52am
plz dont store any image to the database(My advice). Instead store the image in server(probably to ur project folder) and store only the image name in database.
Boipelo 13-Jul-13 10:10am
Why not? scared of a huge database? Then have another database for images. Storing on folder is also a big risk - what happens when the folder gets deleted? All is lost.
jhill444 15-Jul-13 13:54pm
yeah, well, either way, my server admin won't let me put files on the server.
joshrduncan2012 15-Jul-13 13:59pm
I agree with Karthik. You have to factor in scalability when storing large files on database.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 12 Jul 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100