System.IO.DirectoryNotFoundException

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Berryl Hesh

    System.IO.DirectoryNotFoundException

    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[] GetAssemblyPath s() {
    var uri = new Uri(Assembly.Ge tExecutingAssem bly().CodeBase) ;
    var directory = uri.IsAbsoluteU ri ?
    Path.GetDirecto ryName(uri.Abso lutePath) : Directory.GetCu rrentDirectory( );
    return Directory.GetFi les(directory, "*.DLL",
    SearchOption.Al lDirectories);
    }

    Here is the Exception
    /-------------------------------/
    System.IO.Direc toryNotFoundExc eption was unhandled
    Message="Could not find a part of the path
    'C:\\Documents% 20and%20Setting s\\Eric\\My%20D ocuments\\Visua l%20Studio%2020 08\\Projects\\L earning\\Active Record\\src\\Ac tiveRecord.WinT est\\bin\\Debug '."
    Source="mscorli b"
    StackTrace:
    at System.IO.__Err or.WinIOError(I nt32 errorCode, String
    maybeFullPath)
    at System.IO.Direc tory.InternalGe tFileDirectoryN ames(String path,
    String userPathOrigina l, String searchPattern, Boolean includeFiles, Boolean
    includeDirs, SearchOption searchOption)
    at System.IO.Direc tory.GetFiles(S tring path, String searchPattern,
    SearchOption searchOption)
    InnerException:


  • Jay Riggs

    #2
    Re: System.IO.Direc toryNotFoundExc eption

    On Sep 26, 7:59 am, "Berryl Hesh" <efing...@yahoo .comwrote:
    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[] GetAssemblyPath s() {
            var uri = new Uri(Assembly.Ge tExecutingAssem bly().CodeBase) ;
            var directory = uri.IsAbsoluteU ri ?
    Path.GetDirecto ryName(uri.Abso lutePath) : Directory.GetCu rrentDirectory( );
            return Directory.GetFi les(directory, "*.DLL",
    SearchOption.Al lDirectories);
        }
    >
    Here is the Exception
    /-------------------------------/
    System.IO.Direc toryNotFoundExc eption was unhandled
      Message="Could not find a part of the path
    'C:\\Documents% 20and%20Setting s\\Eric\\My%20D ocuments\\Visua l%20Studio%2020 ­08\\Projects\\ Learning\\Activ eRecord\\src\\A ctiveRecord.Win Test\\bin\\Debu g­'."
      Source="mscorli b"
      StackTrace:
           at System.IO.__Err or.WinIOError(I nt32 errorCode, String
    maybeFullPath)
           at System.IO.Direc tory.InternalGe tFileDirectoryN ames(String path,
    String userPathOrigina l, String searchPattern, Boolean includeFiles, Boolean
    includeDirs, SearchOption searchOption)
           at System.IO.Direc tory.GetFiles(S tring 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:\Documen ts and Settings\Eric\M y Documents\Visua l Studio
    2008\Projects\L earning\ActiveR ecord\src\Activ eRecord.WinTest \bin
    \Debug"

    -Jay

    Comment

    Working...