zoukankan      html  css  js  c++  java
  • NDuiker项目第2天总结

    昨天晚上基本上实现了通过托拽文件实现自动查看命令行的功能。总结一下遇到的技术问题和解决办法吧。

    托拽文件到文本框并在文本框显示文件名的办法:

    文本框的AllowDrap=True

        Private Sub txtFilePath_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles txtFilePath.DragEnter
            If e.Data.GetDataPresent(DataFormats.FileDrop) Then
                ' Assign the file names to a string array, in
                ' case the user has selected multiple files.
                Dim files As String() = CType(e.Data.GetData(DataFormats.FileDrop), String())
                Try
                    ' Assign the first image to the 'picture' variable.
                     Me.txtFilePath.Text = files(0)
                Catch ex As Exception
                    MessageBox.Show(ex.Message)
                    Return
                End Try
            End If
        End Sub

    取得临时文件名:
    IO.Path.GetTempFileName

    命令行两边加上双引号解决目录带空格问题:
    Chr(34) & sExecuteFilePath_ & Chr(34)

    读取文件使用编码格式:
    Dim fw As New IO.StreamReader(sTempRedirectFilePath_, System.Text.Encoding.Default)
            ViewReport = fw.ReadToEnd
    不使用这种办法,命令行中的中文提示变成乱码。

    总结:
    目前使用VB.Net来书写,基本上和以前的编程习惯差不多,从昨天的进展看,以前的经验优势真是很有用。

    遇到的问题:
    目前没有判断文件是否为可执行文件?
    文件是32位还是16位?
    文件是否支持命令行?

    PS:
    .Net应该更仔细的应用和了解,通过熟悉它的架构,对编程提高应该是很大的,比如:System.CodeDom.Compiler.TempFileCollection
    应该是一个处理编程中临时文件的类,通常临时文件在程序中有一个生命周期,通过这个类来控制临时文件的产生和销毁,可以很好的保证程序的架构和管理,继续努力吧。
  • 相关阅读:
    URAL 2046 A
    URAL 2056 Scholarship 水题
    Codeforces Gym 100286I iSharp 水题
    Codeforces Gym H. Hell on the Markets 贪心
    Codeforces Gym 100286G Giant Screen 水题
    Codeforces Gym 100286B Blind Walk DFS
    Codeforces Gym 100286F Problem F. Fibonacci System 数位DP
    Codeforces Gym 100286A. Aerodynamics 计算几何 求二维凸包面积
    Codeforces Gym 100418K Cards 暴力打表
    Codeforces Gym 100418J Lucky tickets 数位DP
  • 原文地址:https://www.cnblogs.com/Duiker/p/95142.html
Copyright © 2011-2022 走看看