EXE将从文件夹启动,但不使用UNC路径

时间:2018-11-14 14:40:13

标签: vb.net visual-studio path exe unc

我已经使用Visual Studio Express编译了一个Exe文件,当从文件夹中打开该文件时,它运行得很好,但是当我尝试通过UNC路径(\ Server \ Folder \ Ticker.exe)访问此文件时,此操作失败并显示错误:代码已停止工作。

详细信息: 描述:   停止工作

问题签名:   问题事件名称:CLR20r3   问题签名01:cchticker.exe   问题签名02:1.2.0.2   问题签名03:509134ad   问题签名04:CCHTicker   问题签名05:1.2.0.2   问题签名06:509134ad   问题签名07:d   问题签名08:c6   问题签名09:System.InvalidOperationException   作业系统版本:6.1.7601.2.1.0.256.48   语言环境ID:2057

这是我的代码:

Imports System.Xml
Imports System.Text
Imports System.IO

Public Class Form1
Dim txtTicker As String = "Ticker"
Dim widthX As Single
Dim heightY As Single = 0
Dim g As Graphics
Dim xmlst As String 'string from the xml file
Dim fo As Font
Dim str As String
Dim strwidth As SizeF 'gets the xml string's width and height
Dim douX As Double 'stores the xmlstring's width
Dim newImage As Image = Image.FromFile(Directory.GetCurrentDirectory & "\BHLogo.bmp")
Dim myArray As New ArrayList
Dim counter As Integer
Dim firstloop As Boolean = True

Protected Overrides Sub OnKeyDown(ByVal e As KeyEventArgs)
    MyBase.OnKeyDown(e)

    ' Disable the event if it was an Alt-F4 keypress. 
    If (e.Alt AndAlso e.KeyCode = Keys.F4) Then
        e.Handled = True
    End If
End Sub

Private Sub Form1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDoubleClick
    System.Diagnostics.Process.Start("IExplore.exe", "http://intranet")
End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
    Dim mybrush As New SolidBrush(Color.Red)
    mybrush.Color = Color.FromArgb(99, 101, 107)
    SetStyle(ControlStyles.AllPaintingInWmPaint Or _
    ControlStyles.OptimizedDoubleBuffer Or _
    ControlStyles.UserPaint, True)
    e.Graphics.Clear(Me.BackColor)
    e.Graphics.DrawString(str, fo, mybrush, widthX, heightY + 5)
    Dim ulCorner As New Point(widthX - 75, heightY)
    Dim ulCorner2 As New Point(widthX + douX - 75, heightY)
    e.Graphics.DrawImage(newImage, ulCorner)
    e.Graphics.DrawImage(newImage, ulCorner2)

    Dim i As Integer
    For i = 0 To myArray.Count - 1 Step i + 1
        'Debug.Write(myArray(i) - counter)
        e.Graphics.DrawImage(newImage, New Point(myArray(i) - counter, heightY))
    Next
    i = 0
    e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
    ' e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality()
    e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed

    ' Debug.Write(String.Format("the string width is {0}", CStr(strwidth.Width)))
    If widthX <= (0 - douX) Then
        widthX = Me.Width + 125
        counter = 0
    Else
        widthX -= 1
        counter += 1
    End If

    e.Dispose()

End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) 'Handles Me.Load

    driver()

End Sub

Private Sub driver() Handles Me.Load
    Me.Width = Screen.PrimaryScreen.WorkingArea.Width
    Me.Location = New Point(0, Screen.PrimaryScreen.WorkingArea.Height - 40)
    Me.MaximumSize = New Point(Screen.PrimaryScreen.WorkingArea.Width, 40)
    Me.Height = 40
    Me.MaximizeBox = False
    Me.MinimizeBox = False
    Me.Text = ""
    Me.Icon = Nothing
    Me.ShowInTaskbar = False
    counter = 0



    g = Me.CreateGraphics() 'get the graphics object of the form
    widthX = Me.Width + 125 ' x co- ordinate or width
    ' Debug.Write(String.Format("The width is {0}",
    'CStr(Me.Width)))

    Me.loadthenews()
    ' Dim gr As Graphics
    Timer1.Interval = 1
    Timer1.Start()

    'fo = New Font("ARIAL", 18, FontStyle.Bold, GraphicsUnit.Point)
    'strwidth = g.MeasureString(str, fo)
    'douX = strwidth.Width
End Sub

Private Sub loadthenews()
    str = ""
    myArray.Clear()
    fo = New Font("CALIBRI", 18, FontStyle.Bold, GraphicsUnit.Point)
    Dim readXML As New XmlTextReader(Directory.GetCurrentDirectory & "\news.xml")
    Try
        While readXML.Read()
            If readXML.NodeType = XmlNodeType.Text Then
                If firstloop = True Then
                    str += "    " & readXML.Value
                    If str = " closeme" Then
                        Application.Exit()
                    End If
                Else
                    str += "                   " & readXML.Value
                End If
                firstloop = False

                Dim a = g.MeasureString(str, fo)
                myArray.Add(Me.Width + 125 + a.Width)
            End If
        End While
        strwidth = g.MeasureString(str, fo)
        douX = strwidth.Width + 75

    Catch
        str = "                   Ticker"
        Dim a = g.MeasureString(str, fo)
        'myArray.Add(Me.Width + 125 + a.Width)
    End Try




End Sub

Private Sub form1_hover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseHover
    Timer1.Stop()
    'Debug.Write("In hover!")
End Sub

Private Sub form1_leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseLeave
    Timer1.Start()
    'Debug.Write("In leave!")
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Me.Refresh()
End Sub

Private Sub timer3_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer3.Tick
    'Label1.Visible = True
    'Label1.Text = System.DateTime.Now.ToString("HH:mm:ss")
    If System.DateTime.Now.ToString("mm:ss") = "00:00" Then
        firstloop = True
        Me.loadthenews()
    End If
End Sub

End Class

我希望有人能对此有所了解,因为我不知道它会从文件夹中打开但不使用UNC路径。

欢呼

0 个答案:

没有答案