Vb.net 设置表格';s名称等于拖放文件标题vb
我想在VB中创建一个文本编辑器。我的文本编辑器已经可以读写文本文件了,但我想要比这更好的东西。当我在.exe程序上拖放.txt文件时,我的程序会读取.txt文件的上下文。 但问题是我希望[Form1.Text]是我删除的文件的路径。例如,使用写字板打开文件时,可以在顶部看到文件名:TextFile.txt-Wordpad 这就是代码:Vb.net 设置表格';s名称等于拖放文件标题vb,vb.net,Vb.net,我想在VB中创建一个文本编辑器。我的文本编辑器已经可以读写文本文件了,但我想要比这更好的东西。当我在.exe程序上拖放.txt文件时,我的程序会读取.txt文件的上下文。 但问题是我希望[Form1.Text]是我删除的文件的路径。例如,使用写字板打开文件时,可以在顶部看到文件名:TextFile.txt-Wordpad 这就是代码: Private Sub ReadingText(sender As Object, e As EventArgs) Handles Me.Load Dim
Private Sub ReadingText(sender As Object, e As EventArgs) Handles Me.Load
Dim arguments As String = Command()
If arguments = String.Empty Then
RichTextBox1.Text += vbCrLf & vbCrLf & vbCrLf
Else
Dim tempstr As String = arguments.Replace("""", "")
Dim SR As New System.IO.StreamReader(tempstr)
RichTextBox1.Text = vbCrLf & SR.ReadToEnd
Try
SR.Close()
Catch ex As Exception
RichTextBox1.Text += ex.ToString
End Try
End If
End Sub
您能帮忙吗???您已经在
tempstr
变量中获得了文件名,只需使用它:
Dim tempstr As String = arguments.Replace("""", "")
Me.Text = tempstr & " - YourTextEditorNameHere"
Dim SR As New System.IO.StreamReader(tempstr)
如果不需要完整路径,请使用:
如果不需要扩展,请使用:
在问题被否决之前,编辑你的标题以适应它。说你想要更好的东西是相当广泛的。具体地说,你不太可能在这里找到任何帮助,因为这个问题现在就存在。谢谢,太多了!这正是我想要的:)我保证以后会说得更具体些。。
Dim tempstr As String = arguments.Replace("""", "")
Me.Text = System.IO.Path.GetFileName(tempstr) & " - YourTextEditorNameHere"
Dim SR As New System.IO.StreamReader(tempstr)
Dim tempstr As String = arguments.Replace("""", "")
Me.Text = System.IO.Path.GetFileNameWithoutExtension(tempstr) & " - YourTextEditorNameHere"
Dim SR As New System.IO.StreamReader(tempstr)