Hi
On below line i am getting error - could not find file. though file exists.
System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(@"\\10.0.1.110\Attachments\3b2 1606");
Thanks
Hi
On below line i am getting error - could not find file. though file exists.
System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(@"\\10.0.1.110\Attachments\3b2 1606");
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Emily FosterPosted Mar 17, 2025, 6:50 AM
It seems like the error message you are encountering, "could not find file," occurs even when the file exists at the specified path. This issue commonly arises due to permission problems, network-related issues, or inaccuracies in the path specified.
Here are a few steps to troubleshoot this problem:
1. Permissions: Ensure that the user account under which your application is running has the necessary permissions to access the file on the network share. Lack of permissions can result in such errors.
2. Network Connectivity: Check the network connectivity to the file location `\\10.0.1.110\Attachments\`. Make sure that the server is accessible from the machine running your code and that there are no network interruptions causing the file not to be found.
3. Path Accuracy: Double-check the file path `\\10.0.1.110\Attachments\3b2 1606` for any typos, spaces, or special characters that might be causing the file not to be found. Sometimes, certain characters can create issues.
4. Handling Exceptions: Surround the file access code with try-catch blocks to capture any exceptions thrown. This can provide more detailed information about why the file is not being found.
Here is a modified version of your code snippet with exception handling included:
By incorporating these steps and being mindful of permissions, network connectivity, accurate paths, and proper exception handling, you can troubleshoot the "could not find file" error effectively. Let me know if you need further assistance or clarification on any of these points!