如题,求上面的一段代码,谢谢了。
解决方案 »
- X轴有重复值的交易走势图如何实现?
- 在线请教:datagridview与bindingsorce
- c#生成word中:如何设置某行文字的大小,颜色并居中
- 问个关于视图的效率的问题
- 请问在FORM编程中如何使datagrid可修改但不能添加新的记录
- 请高手来看看,为什么DataGrid分页没反应啊
- 麻烦前辈们,我想通过进程获取金城路径,但是有的进程获取就会报错
- DataGrid的里利用新增加的空间进行增加记录,修改记录,选中删除的操作~~
- 打家来讨论一下(参加有分100)
- look at ,
- 关于Execute 语句中调用自定义函数问题(函数中有参数)
- 自定义DataGridView类,如何增加右键菜单
public static class StreamHelper
{
public static Encoding GetEncoding(Stream stream, Encoding defaultEncoding)
{
Encoding targetEncoding = defaultEncoding; if (stream == null) return targetEncoding;
if (stream.Length < 3) return targetEncoding; byte byte1, byte2, byte3; //保存当前Seek位置
long origPos = stream.Seek(0, SeekOrigin.Begin);
byte1 = Convert.ToByte(stream.ReadByte());
byte2 = Convert.ToByte(stream.ReadByte());
byte3 = Convert.ToByte(stream.ReadByte()); //根据文件流的前3个字节判断Encoding
if (byte1 == 0xFE && byte2 == 0xFF)//UnicodeBe
{
targetEncoding = Encoding.BigEndianUnicode;
} if (byte1 == 0xFF && byte2 == 0xFE && byte3 != 0xFF)//Unicode
{
targetEncoding = Encoding.Unicode;
} if (byte1 == 0xEF && byte2 == 0xBB && byte3 == 0xBF)//UTF8
{
targetEncoding = Encoding.UTF8;
} //恢复Seek位置
stream.Seek(origPos, SeekOrigin.Begin); return targetEncoding;
}
}
private void InitComboBox()
{
List<string> ServerNames = new List<string>();
ServerNames = this.LoadName();
this.cmbServer.Items.AddRange(ServerNames.ToArray());
this.cmbCategory.Items.AddRange(new string[] { "Error", "Exception", "Info" });
} private void SetSavePath(ref string savePath)
{
FolderBrowserDialog FolderPath = new FolderBrowserDialog();
FolderPath.ShowDialog();
savePath = FolderPath.SelectedPath;
} private void btnDownloadBatch_Click(object sender, EventArgs e)
{
DateTime dt = this.dtpStart.Value;
string savePath = String.Empty; Server = this.cmbServer.Text;
Path = this.txtPath.Text + @"\Log\" + cmbCategory.Text;
if (!Directory.Exists(Path)) { MessageBox.Show("路径不存在"); return; }
SetSavePath(ref savePath); //下面那两句防止间隔小于24小时但跨越两天才算一天的情况
DateTime start = new DateTime(this.dtpStart.Value.Year, this.dtpStart.Value.Month, this.dtpStart.Value.Day, 0, 0, 0);
DateTime end = new DateTime(this.dtpEnd.Value.Year, this.dtpEnd.Value.Month, this.dtpEnd.Value.Day, 23, 59, 59); TimeSpan ts = end - start;
double dDays = ts.TotalDays;//带小数的天数,比如1天12小时结果就是1.5
int DateCount = (int)Math.Ceiling(dDays);//返回有效数就进一的整数 this.progressBar1.Value = 0;
DownLoadBatch(dt, end, DateCount, savePath);
}