File tree Expand file tree Collapse file tree
Common.BasicHelper.Test/IO Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -166,4 +166,25 @@ public void Test_ByteToFile()
166166 for ( int i = 0 ; i < read . LongLength ; ++ i )
167167 Assert . AreEqual ( read [ i ] , bytes [ i ] ) ;
168168 }
169+
170+ [ TestMethod ( ) ]
171+ public void Test_CreateFile ( )
172+ {
173+ var file = Path . GetTempFileName ( ) ;
174+
175+ file . Print ( ) ;
176+
177+ var bytes = Encoding . UTF8 . GetBytes ( "Test" ) ;
178+
179+ FileHelper . CreateFile ( bytes , file ) ;
180+
181+ var read = FileHelper . ReadAllBytes ( file ) ;
182+
183+ File . Delete ( file ) ;
184+
185+ Assert . AreEqual ( read . LongLength , bytes . LongLength ) ;
186+
187+ for ( int i = 0 ; i < read . LongLength ; ++ i )
188+ Assert . AreEqual ( read [ i ] , bytes [ i ] ) ;
189+ }
169190}
Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ public static byte[] ReadAllBytes(string path)
165165 /// </summary>
166166 /// <param name="fileBuffer">二进制流</param>
167167 /// <param name="newFilePath">文件路径</param>
168- private static void CreateFile ( byte [ ] fileBuffer , string newFilePath )
168+ public static void CreateFile ( byte [ ] fileBuffer , string newFilePath )
169169 {
170170 if ( File . Exists ( newFilePath ) )
171171 File . Delete ( newFilePath ) ;
You can’t perform that action at this time.
0 commit comments