Error in C# application . System.ArgumentException: The path is not of a legal form?

偶尔善良 提交于 2021-02-20 05:01:09

问题


I am not getting why this error is coming i serach in net and not able to get answer . Technologies using : C#
Visual Studio for debugging the project

I have a code

 private void InitializeWatcher(string sourceDirectoryPath, string watcherFilter, bool isWatcherIncludeSubdirectories)
        {
            objWatcher = new FileSystemWatcher();
            objWatcher.IncludeSubdirectories =isWatcherIncludeSubdirectories;
            objWatcher.InternalBufferSize = 16384;

            if (Utilities.LogLevel >= Utilities.Informational)
            {
                Utilities.LogMessage("InitializeWatcher: " + sourceDirectoryPath, EventLogEntryType.Information);
            }
            System.Console.WriteLine( "sjdakdjasdhas ");
            System.Console.WriteLine( sourceDirectoryPath);
            objWatcher.Path = sourceDirectoryPath;
            objWatcher.Filter = watcherFilter;
            objWatcher.Created += new FileSystemEventHandler(objWatcher_FileSystemEvent);
            objWatcher.Changed += new FileSystemEventHandler(objWatcher_FileSystemEvent);
            objWatcher.Deleted += new FileSystemEventHandler(objWatcher_FileSystemEvent);
            objWatcher.Error += new ErrorEventHandler(objWatcher_Error);
            try
            {
                objWatcher.EnableRaisingEvents = true;
            }
            catch (Exception camp)
            {
                System.Console.WriteLine("camp -->");
                System.Console.WriteLine(camp);
            }
            FileSystemEventArgs objFileSystemEventArgs = new FileSystemEventArgs(WatcherChangeTypes.Changed, objWatcher.Path+"\\","\\");
            objWatcher_FileSystemEvent(objWatcher, objFileSystemEventArgs);
            watcherQueue.Add(objWatcher);
        }

When have run the code and it gives error like this.

sjdakdjasdhas 
\\10.197.132.58\share1
camp -->
System.ArgumentException: The path is not of a legal form.
   at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.GetFullPathInternal(String path)
   at System.IO.Path.GetFullPath(String path)
   at System.IO.FileSystemWatcher.StartRaisingEvents()
   at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
   at xyzprojectpath.FileSystemWatcherWrapper.InitializeWatcher(String sourceDirectoryPath, String watcherFilter, Boolean isWatcherIncludeSubdirectories) in xyzpath\FileSystemWatcherWrapper.cs:line 123

Any help? I don't know about .NET to much . If needed more code please let me know .

Error is coming on this line

objWatcher.EnableRaisingEvents = true;

来源:https://stackoverflow.com/questions/48002796/error-in-c-sharp-application-system-argumentexception-the-path-is-not-of-a-le

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!