In a C# 2008 console application, I have a line of code that fails a try catch block.
The line of code is:
System.IO.FileStream fileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
The wholse section of code looks like:
public Attachment AttIputDoc(String custId, String fileName)
{
Attachment att = new Attachment();
byte[] buffer = null;
try
System.IO.FileStream fileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
catch (Exception e)
{
}
The line of code is trying to access a file that does not exist in a specific location.
Can you tell me how the code listed above knows where the directory path is for the file that needs to get uploaded at? The place it thinks the file needs to be loaded from is where the source code of where the application is acutally running from.
How would I override the default location so I can obtain the value from the app.config file?
Loading
dcPosted Sep 17, 2012, 10:57 PM
I want to ask/mention the following items:
1. The code I am running was obtained from a contract shop. They just gave me the shell of what they thought I needed.
2. I can not open the code you gave to me since due to company security restrictions. Also isn't a *.jar file a java archive file and can that be used with a C# application?
Thus can you just display the code that you included in the *.jar file for me to copy and use?
Akkiraju IvaturiPosted Sep 17, 2012, 3:09 PM
1. Add reference to System.Configuration to be able to access application configuration settings for Folder path.
2. You need to check if file exists rather than telling the try catch to handle the exception.
Find the attachment which may help you in fixing the problem
Let me know if you have any questions.