Search code examples
c#windows-servicesdirectory

The directory name is invalid


Why am I getting this error? I am using the correct path.

Directory name is invalid


Solution

  • Problem : You are providing the Path of File

    Solution : You need to provide the path of Directory to get all the files in a given Directory based on your search pattern.

    From MSDN: Directory.GetFiles()

    Returns the names of files (including their paths) that match the specified search pattern in the specified directory.

    Try this:

    string directoryName = Path.GetDirectoryName(e.FullPath);
    foreach(String filename in Directory.GetFiles(directoryName,"*.eps"))
    {   
        //your code here   
    }