GetAppProfilePath("文件夹2");
private static string GetAppProfilePath(string foldType)
{
Assembly asm = Assembly.GetEntryAssembly() ;
string path = Path.GetDirectoryName(asm.Location) ; string[] dirs = null ;
while ( true )
{
dirs = Directory.GetDirectories(path, foldType) ;
if ( dirs.Length > 0 ) break ; DirectoryInfo dirInfo = Directory.GetParent(path) ;
if ( dirInfo == null ) break ;
path = dirInfo.FullName ;
}
return ( dirs != null ) ? dirs[0] : null ;
}
private static string GetAppProfilePath(string foldType)
{
Assembly asm = Assembly.GetEntryAssembly() ;
string path = Path.GetDirectoryName(asm.Location) ; string[] dirs = null ;
while ( true )
{
dirs = Directory.GetDirectories(path, foldType) ;
if ( dirs.Length > 0 ) break ; DirectoryInfo dirInfo = Directory.GetParent(path) ;
if ( dirInfo == null ) break ;
path = dirInfo.FullName ;
}
return ( dirs != null ) ? dirs[0] : null ;
}
if(!Directory.Exists(path)) //判断path路径是否存在
{
Directory.CreateDirectory(path); //如不存在则创建
}2、string path = Server.MapPath(@"..\文件夹2\文件夹3")+direcotryName+"\\";//这里是变量
if(!Directory.Exists(path)) //判断path路径是否存在
{
Directory.CreateDirectory(path); //如不存在则创建
}
以上代码未经调试,如有错误还请自行更正~~~