System.IO.DirectoryNotFoundException

B

Berryl Hesh

I don't know where the "%" sysmbols are coming from, but without them this
is a valid directory. I've pasted both the exception and code that
triggeered it below. The purpose of this code block is to gather a list of
dll's.

Thanks - BH


Here is the Code
/-------------------------------/
private static string[] GetAssemblyPaths() {
var uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
var directory = uri.IsAbsoluteUri ?
Path.GetDirectoryName(uri.AbsolutePath) : Directory.GetCurrentDirectory();
return Directory.GetFiles(directory, "*.DLL",
SearchOption.AllDirectories);
}

Here is the Exception
/-------------------------------/
System.IO.DirectoryNotFoundException was unhandled
Message="Could not find a part of the path
'C:\\Documents%20and%20Settings\\Eric\\My%20Documents\\Visual%20Studio%202008\\Projects\\Learning\\ActiveRecord\\src\\ActiveRecord.WinTest\\bin\\Debug'."
Source="mscorlib"
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String
maybeFullPath)
at System.IO.Directory.InternalGetFileDirectoryNames(String path,
String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean
includeDirs, SearchOption searchOption)
at System.IO.Directory.GetFiles(String path, String searchPattern,
SearchOption searchOption)
InnerException:
 
J

Jay Riggs

I don't know where the "%" sysmbols are coming from, but without them this
is a valid directory. I've pasted both the exception and code that
triggeered it below. The purpose of this code block is to gather a list of
dll's.

Thanks - BH

Here is the Code
/-------------------------------/
    private static string[] GetAssemblyPaths() {
        var uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
        var directory = uri.IsAbsoluteUri ?
Path.GetDirectoryName(uri.AbsolutePath) : Directory.GetCurrentDirectory();
        return Directory.GetFiles(directory, "*.DLL",
SearchOption.AllDirectories);
    }

Here is the Exception
/-------------------------------/
System.IO.DirectoryNotFoundException was unhandled
  Message="Could not find a part of the path
'C:\\Documents%20and%20Settings\\Eric\\My%20Documents\\Visual%20Studio%2020­08\\Projects\\Learning\\ActiveRecord\\src\\ActiveRecord.WinTest\\bin\\Debug­'."
  Source="mscorlib"
  StackTrace:
       at System.IO.__Error.WinIOError(Int32 errorCode, String
maybeFullPath)
       at System.IO.Directory.InternalGetFileDirectoryNames(String path,
String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean
includeDirs, SearchOption searchOption)
       at System.IO.Directory.GetFiles(String path, String searchPattern,
SearchOption searchOption)
  InnerException:

Berryl,

The %20 is just the hex code for a space character.

I wonder if you'd get the same error if you replaced your "directory"
variable in your GetFiles method call with the hard coded value (watch
out for wrap):
@"C:\Documents and Settings\Eric\My Documents\Visual Studio
2008\Projects\Learning\ActiveRecord\src\ActiveRecord.WinTest\bin
\Debug"

-Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top