Can I tell the nonexistent path in case of DirectoryNotFound exception? - c#

I am building an application which copies or moves files from and to various network drives. It seems to me that File.Move and File.Copy throws:
System.IO.DirectoryNotFoundException: Could not find a part of the
path
due to permission problems for user running the application. However, the exception message does not contain information of which folder the application fails to find (ex.Message is only Could not find a part of the path and there is no inner exception), so it is hard for the users to check which permission they need to check by looking at the exception message directly.
Is there a way to find which folder is causing the exception to be thrown? The documentation of the exception does not seem to show any property for this.

Related

Synchronization error in Kentico 8.0.21

While trying to synchronize in Kentico, a user go this error:
Synchronization server error: Exception occurred: Access to the path 'C:\inetpub\wwwroot\92YOrg\CMSFiles\f3\f3ef02ff-84bf-4ccb-b815-b807d8fd35f6.jpg' is denied.
The thing is that the file in question is actually on the E drive instead of the C drive, as it says in the error. So why would Kentico think to look in the C drive? I'm guessing that there is a setting somewhere that needs to be changed, but I've had no luck finding it. Thanks for your time.
First, I'd go back to your website in IIS and actually determine where in the file system your website is mapped to.
Second, ensure you have proper permissions set on the directories in the file system.
Try to check System > File > Storage in Settings application.

File visible as normal user but not as Admin

I am building an universal updater for my company, and when I try to access a mapped network drive, the program throws a file not found exception when run as admin. When the file is run as a normal user the files are visible, but throws an Unauthorized Exception due to the fact that the files are copied to the Program Files (company policy).
Edit
The code that throws the FileNotFound Exception is FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(rdrInner.GetString(2)); and the Unauthorized Exception is thrown by File.Copy(pi.RemotePath, pi.Path, true);
Mapped drives are part of the user profile, so you need to map the drive whilst logged in as the admin user. This is why using a mapped drive is a bad idea--can't you use a fully qualified UNC path instead? See http://msdn.microsoft.com/en-gb/library/gg465305.aspx for an explanation of UNC paths.

how to suppress error 1606- could not access network location in wix

I am installing some component in network location. At the time of uninstall, if network location is unavailable because remote machine is not on. setup is giving following error
Error 1606 could not access network location
Is there any way to suppress this error and continue the uninstallation process?
If the files on Network location(that is unavailable at the time) are not deleted then its ok for me.
To fix your issue you could try and set the component to Permanent ="yes" which will not un-install that component and in theory you should not get that error.
However personally I would re-think the implementation to get around adding files to the network location (maybe add the network files on first run of your application?).

Publishing my Website to my Local Disk Causes Exceptions to show Paths including my Local Disk

I've published my website many times. But didn't think about this though until I came across this issue. So I decided to publish my WAP project to a local folder on my C drive first. Then used FTP to upload it to my shared host on discountasp.net. I noticed during runtime that the stack trace was referencing that local folder still and erroring out.
Anyone know what config settings are affected when publishing? Obviously something is still pointing to my local C drive and I've searched my entire solution and don't see why.
Here's the runtime error I get when my code tries to run in discountasp.net's web server
Cannot write into the public directory - check permissions
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: ScrewTurn.Wiki.PluginFramework.InvalidConfigurationException: Cannot write into the public directory - check permissions
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidConfigurationException: Cannot write into the public directory - check permissions]
ScrewTurn.Wiki.SettingsStorageProvider.Init(IHostV30 host, String config) in C:\www\Wiki\Screwturn3_0_2_509\Core\SettingsStorageProvider.cs:90
ScrewTurn.Wiki.StartupTools.Startup() in C:\www\Wiki\Screwturn3_0_2_509\Core\StartupTools.cs:69
ScrewTurn.Wiki.Global.Application_BeginRequest(Object sender, EventArgs e) in C:\www\Wiki\Screwturn3_0_2_509\WebApplication\Global.asax.cs:29
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Discountasp says it's not a permission issue but obviously it is.
The .pdb file is what's pointing to your local directory, that's not to say anything in the site is, that's an unrelated issue. Wherever the project was compiled ad the .pdb files created, those are the paths that will appear in the stack trace.
These directory entries have no bearing on where the application is actually deployed, it's mainly just so you can see where the class that errored out is located (and hopefully you as a developer can go "oh yeah, that damn class again"). If you posted the stack we may be able to help...but the fact that the directory points to your C:\ drive is nothing to worry about, this is absolutely normal.

How can I use Directory.GetFiles skipping UnauthorizedAccessException?

When I use System.IO.Directory.GetFiles method in C:\, an error is raised:
Access to the path 'c:\System Volume Information' is denied.
How can I handle that?
It's a hidden system folder and the reason you are getting this error is because your application is running under your local account.

Categories