#region using directives
using system;
using system.io ;
using system.xml ;
using system.collections ;
using system.reflection ;
using system.text ;
using system.data ;
using system.componentmodel;
using system.windows.forms;
using system.drawing;
using system.threading ;
#endregion
public class frmmain : system.windows.forms.form
///
/// 清理所有正在使用的資源。
///
protected override void dispose( bool disposing )
}base.dispose( disposing );
}#region initialize components
///
/// 設計器支援所需的方法 - 不要使用**編輯器修改
/// 此方法的內容。
///
private void initializecomponent()
#endregion
///
/// entry point
///
#endregion
int totalsize; //total size
int position; //position
const int buffer_size = 4096;
byte buffer;
stream stream;
private void btncopy_click(object sender, system.eventargs e)
else
filestream fs = new filestream( strfile , filemode.open , fileaccess.read ) ;
totalsize = (int)fs.length ;
stream = fs;
//delete file which aready exists.
if ( file.exists( "c://copyedfile.bin" ) )
file.delete( "c://copyedfile.bin" );
//copy file while larger than 4kb.
if ( totalsize > buffer_size )
else
}///
/// asynchronously copy file
///
///
private void asynccopyfile( iasyncresult ar )
// current stream position
position += readedlength;
// response ui
methodinvoker m = new methodinvoker( synchprogressbar );
m.begininvoke( null , null );
if ( position >= totalsize ) // read over.
// continue to read and write
lock ( stream )
}private void synchprogressbar()}}
使用C 在進度條中顯示複製檔案的進度
public class frmmain system.windows.forms.form 清理所有正在使用的資源。protected override void dispose bool disposing base.dispose disposing region initialize com...
使用C 在進度條中顯示複製檔案的進度
region using directives using system using system.io using system.xml using system.collections using system.reflection using system.text using system....
使用C 在進度條中顯示複製檔案的進度
region using directives using system using system.io using system.xml using system.collections using system.reflection using system.text using system....