Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
Ftt_Common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Ftt_Common
Commits
4938dcb0
Commit
4938dcb0
authored
Oct 13, 2021
by
tr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日志查看:优化空日志显示
parent
094093a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
wLogViewer.cs
Tools/UI/wLogViewer.cs
+12
-5
No files found.
Tools/UI/wLogViewer.cs
View file @
4938dcb0
...
...
@@ -31,7 +31,6 @@ namespace Tools.UI
var
list
=
new
List
<
string
>
{
Encoding
.
Default
.
HeaderName
.
ToUpper
(),
Encoding
.
UTF8
.
HeaderName
.
ToUpper
(),
Encoding
.
ASCII
.
HeaderName
.
ToUpper
(),
};
this
.
tscbEncoding
.
Items
.
AddRange
(
list
.
Distinct
().
ToArray
());
this
.
tscbEncoding
.
SelectedIndex
=
0
;
...
...
@@ -133,14 +132,15 @@ namespace Tools.UI
if
(
token
.
IsCancellationRequested
)
return
;
//读取日志内容
var
buffer
=
new
byte
[
1024
];
var
initLength
=
1024
;
var
buffer
=
new
byte
[
initLength
];
var
fs
=
new
FileStream
(
$@"
{
this
.
LogPath
}
\
{
fileName
}
"
,
FileMode
.
Open
,
FileAccess
.
Read
);
//初始化进度条
this
.
AsyncUI
(()
=>
{
this
.
progressBar1
.
Maximum
=
Math
.
Max
(
1
,
(
int
)(
fs
.
Length
/
1024
));
this
.
progressBar1
.
Maximum
=
Math
.
Max
(
1
,
(
int
)(
fs
.
Length
/
initLength
));
this
.
progressBar1
.
Value
=
0
;
});
StringBuilder
sb
=
new
StringBuilder
(
1024
);
StringBuilder
sb
=
new
StringBuilder
(
initLength
);
while
(
fs
.
Read
(
buffer
,
0
,
buffer
.
Length
)
>
0
)
{
this
.
AsyncUI
(()
=>
...
...
@@ -151,7 +151,14 @@ namespace Tools.UI
sb
.
Append
(
encode
.
GetString
(
buffer
));
}
//显示日志内容
this
.
AsyncUI
(()
=>
this
.
textBox1
.
Text
=
sb
.
ToString
());
this
.
AsyncUI
(()
=>
{
this
.
textBox1
.
Text
=
sb
.
ToString
();
if
(
this
.
textBox1
.
Text
.
Length
==
0
)
{
this
.
progressBar1
.
Value
=
this
.
progressBar1
.
Maximum
;
this
.
textBox1
.
Text
=
"***该日志文件为空***"
;
}
});
//释放资源
sb
.
Clear
();
fs
.
Close
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment