使用C 在進度條中顯示複製檔案的進度

2021-03-31 08:56:58 字數 1686 閱讀 4529

#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.***ponentmodel;

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 ***ponents

///

/// 設計器支援所需的方法 - 不要使用**編輯器修改

/// 此方法的內容。

///

private void initialize***ponent()

#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 )

return ;}

// 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....