ns am emerging website utilizing Visual Studio 2010. Ns am make the efforts to save a record in a path. It functions fine localhost.

But the same code is not functioning in IIS. It mirrors the adhering to error

Exception Details: System.IO.DirectoryNotFoundException: might not discover a component of the course "C:InetpubwwwrootVendorcn.jpg".

You are watching: Could not find a part of the path

Could not uncover a component of the course "C:UsersshashankDesktopab.csv".

Here is the code:

protected void btnImportFile_Click(object sender, EventArgs e) sArReportText = File.ReadAllText(txtFilePath.Text.Trim()); // collection the report properties to insert Report info SetProperties();
c# asp.net visual-studio-2010 filenotfoundexception
re-superstructure
enhance this concern
follow
edited Aug 2 "15 at 13:49

*

durron597
31.1k1616 yellow badges9595 silver badges152152 bronze badges
request Sep 11 "13 in ~ 11:57
*

ShashankShashank
5,6472020 gold badges4949 silver- badges7171 bronze title
7
| show 2 an ext comments

7 answers 7


active oldest Votes
5
You might likewise be suffering what ns am: the the magazine name contains some unexplained characters. In my case,

So using principles drawn indigenous Obtaining the short 8.3 filename native a long filename, I transform my paths to short type first, then usage that to gain my list of files.

StringBuilder sf = new StringBuilder(300);int n = GetShortPathName(sourceFolder, sf, 300);if (0 == n) tk.write(Marshal.GetLastWin32Error().ToString()); continue;...

IEnumerable fileGroup = Directory.EnumerateFiles(sf.ToString(), ext);
re-superstructure
improve this price
follow
edited Feb 27 "20 in ~ 5:16

*

Prashant Pimpale
9,17477 gold badges3333 silver badges7272 bronze title
answered Aug 26 "15 at 6:19
*

bugmagnetbugmagnet
7,34177 gold badges6161 silver badges123123 bronze badges
add a comment |
1
This might be because, you are not having the specified file in net server, or you may be supplied an untrue path. Specify the precise folder and also filename as exactly how it is stored in the net server. Usage HttpContext.Current.Request.ApplicationPath or Server.MapPath to specify the correct ar where your desired paper lies. And additionally make certain that you have provided read and write permissions because that this specific record and its folder.


re-publishing
enhance this answer
follow
reply Sep 11 "13 in ~ 12:05
*

Robin JosephRobin Joseph
1,00011 yellow badge99 silver badges1212 bronze title
include a comment |
1
Consider just how you"re launching VS too. Counter-intuitively ns run into this difficulty only when I"m running VS in Administrator mode. Perhaps a team policies thing.


re-superstructure
improve this answer
monitor
reply Dec 20 "18 in ~ 0:34
Ben PowerBen strength
1,52633 yellow badges2222 silver- badges3232 bronze badges
include a comment |
0
You require to have permissions set in iis to enable files come be saved in the folder. Basically your uploaded files should be saved inside a different folder current inside your root directory.


share
enhance this answer
follow
answered Sep 11 "13 at 12:00
BibhuBibhu
3,99344 gold badges3030 silver- badges6161 bronze title
add a comment |
0
In order to access, create and delete records on the server, must have actually rights.Like in my project I am using Impersonator course to access various files and also folder from the server.Otherwise it will certainly throw one exception.


re-publishing
enhance this answer
follow
answer Sep 11 "13 at 13:29
JulyOrdinaryJulyOrdinary
3,29566 gold badges4545 silver badges7676 bronze title
include a comment |
0
You could use password impersonation:

http://csharptuning.blogspot.com/2007/06/impersonation-in-c.htmlhttp://www.codeproject.com/Articles/14358/User-Impersonation-in-NET

regardless, whomever you use as the impersonation must be able to read/write come the place that is being conserved to. We usage this technique in applications because that delete/create folders throughout network. Even if App_Data is best practice, it might be a business requirement to accessibility the papers outside of that folder.

You can also set impersonation on IIS.

I also notice that your function is dubbed btnImportFile. You might want to look into FileUpload control if you space uploading a file, which enables you to acquire the byte array of the paper and conserve as needed. Https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload%28v=vs.110%29.aspx. You can still need to use Server.MapPath or HttpContext.Current.Request.ApplicationPath relying on your needs.


share
enhance this prize
monitor
reply Jul 2 "15 in ~ 4:59
jmcclurejmcclure
1221010 bronze title
add a comment |
-3
It"s usually ideal practice to usage the App_Data folder to save files to.

Take a watch here, Working through files, because that a tutorial.


share
boost this answer
follow
answered Sep 11 "13 in ~ 13:33
Christian PhillipsChristian Phillips
17k88 gold badges4747 silver- badges7676 bronze badges
1
include a comment |

your Answer


Thanks for contributing solution to stack Overflow!

Please be sure to answer the question. Carry out details and also share your research!

But avoid

Asking for help, clarification, or responding to various other answers.Making statements based on opinion; earlier them increase with referrals or personal experience.

To find out more, check out our tips on writing great answers.

See more: Book Review: " What Every Environmentalist Needs To Know About Capitalism :


Draft saved
Draft discarded

Sign increase or log in in


sign up using Google
sign up using Facebook
authorize up making use of Email and also Password
submit

Post together a guest


surname
email Required, yet never shown


Post together a guest


surname
email

Required, yet never shown


article Your prize Discard

By clicking “Post her Answer”, you agree to our regards to service, privacy policy and cookie plan


Not the prize you're spring for? Browse various other questions tagged c# asp.net visual-studio-2010 filenotfoundexception or questioning your very own question.


The Overflow Blog
Featured ~ above Meta
connected
838
Metadata document '.dll' can not be uncovered
1821
just how do i remedy "The breakpoint will certainly not at this time be hit. No symbols have been invited for this document." warning?
590
The inquiry was aborted: could not create SSL/TLS secure channel
439
HTTP Error 503, the company is do not have
2
after switching visual Studio come use regional IIS server, image and also style files not uncovered
1567
Why not inherit native List?
1095
could not find a component of the path ... Bin oslyncsc.exe
0
“Could not find a part of the path” asmx web service
hot Network concerns much more hot questions

concern feed
subscribe to RSS
question feed To subscribe to this RSS feed, copy and paste this URL right into your RSS reader.


lang-cs
stack Overflow
commodities
agency
stack Exchange Network
site style / logo design © 2021 stack Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.11.4.40656


Stack Overflow works best with JavaScript enabled
*

her privacy

By click “Accept all cookies”, girlfriend agree ridge Exchange have the right to store cookies on your maker and disclose details in accordance v our Cookie Policy.