/// <summary> /// 验证保存文件 /// </summary> private static void ValidateSave( FileInfo file ) { file.CheckNull( "file" ); if ( file.FileBytes == null || file.FileBytes.Length == 0 ) throw new Warning( string.Format( R.InvalidFile,file.FileName ) ); if( file.GetPhysicalPath().IsEmpty() ) throw new ArgumentException("上传路径不正确"); }
/// <summary> /// 创建目录 /// </summary> private static void CreateDirectory( FileInfo file ) { var path = Path.GetDirectoryName( file.GetPhysicalPath() ); if ( path == null ) return; if ( Directory.Exists( path ) ) return; Directory.CreateDirectory( path ); }
/// <summary> /// 验证保存文件 /// </summary> private static void ValidateSave(FileInfo file) { file.CheckNull("file"); if (file.FileBytes == null || file.FileBytes.Length == 0) { throw new Warning(string.Format(R.InvalidFile, file.FileName)); } if (file.GetPhysicalPath().IsEmpty()) { throw new ArgumentException("上传路径不正确"); } }
/// <summary> /// 创建目录 /// </summary> private static void CreateDirectory(FileInfo file) { var path = Path.GetDirectoryName(file.GetPhysicalPath()); if (path == null) { return; } if (Directory.Exists(path)) { return; } Directory.CreateDirectory(path); }
/// <summary> /// 保存文件 /// </summary> private static void SaveFile( FileInfo file ) { Write( file.GetPhysicalPath(), file.FileBytes ); }
/// <summary> /// 保存文件 /// </summary> private static void SaveFile(FileInfo file) { Write(file.GetPhysicalPath(), file.FileBytes); }