How to solve the problem with the recording file in the application folder ASP.NET (IIS)?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
28 views
Hello.

Faced the following problem:
stopped recording the files to a local folder of the application that is hosted on IIS.

Application architecture:
App ASP.NET MVC 3, it has several WCF services. One of them just provides the functionality of file upload. Clint this service is Silverlit app. It is through download. Method inside the client asynchronously pulls a web service and gives him bundles of data that must be recorded.

I added a new web service app but after I tadalail new version stopped working this functionality. Rollback to older version did not help.
Locally all cresterea and works (both new and old version).
With logging I found out that not performs the next piece of code:
void SendFile() { // some code, which you can track //Open modes need to be specified, but they have not changed for many years using (FileStream stream = File.Open(filename, FileMode.Append, FileAccess.Write, FileShare.Read)) { // using is not transmitted inside the control, nothing to catch try { // } catch (Exception ex) { // } } }


Falls, apparently, on the creation of the thread. Suspected write.
IIS 7 pool .NET 4 turns.

In the logs, IIS throws the 500 error. While more can not be obtained due to characteristics of the system.

Can prompt where to dig? Rights to IIS looked, everything looked OK.
Later can Supplement the information.
by | 28 views

2 Answers

0 like 0 dislike
Rewrote the code so that it was possible to catch the error. Given: System.IO.DirectoryNotFoundException: Could not find a part of the path

I found a bunch of interesting questions and answers:
\rstackoverflow.com/questions/18740564/system-io-dir...
\rwww.codeproject.com/Questions/658980/Could-not-fin...
\rsupport.microsoft.com/kb/827421

Solution:
To manually create the folder where will be written the file.

string dir = Path.GetDirectoryName(filePath); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); FileStream stream = null; try { stream = File.Open(filename, FileMode.Append, FileAccess.Write, FileShare.Read); .... } catch(Exception ... ) { ... } finally { if(stream != null) stream.Dispose() }
by
0 like 0 dislike
You can try to deploy using and get exception

FileStream stream = null; try { stream = File.Open(filename, FileMode.Append, FileAccess.Write, FileShare.Read); .... } catch(Exception ... ) { ... } finally { if(stream != null) stream.Dispose() }
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
36,634 users