0

txt ファイルを含むフォルダーを開く次のコードがあります。

Private Sub OpenTabpageTextFolderToolStripMenuItem_Click( _
            ByVal sender As System.Object, ByVal e As System.EventArgs) _
            Handles OpenTabpageTextFolderToolStripMenuItem.Click
  Dim OpenFolder = (RootDrive & "QuickEmailer2\TabTxt")
  Process.Start("explorer.exe", OpenFolder)
End Sub

次に、ユーザーは txt ファイルを編集して閉じます。更新コードを呼び出して txt ファイルの変更を利用したいのですが、process.start の後に呼び出しを行うと、待機せずに実行されますか?

コードを使用してこれらの編集を行うこともできますが、選択できるファイルは 80 個あり、最初にプログラムをセットアップするときに 1 回 (または 2 回) 編集するだけで済みます。

私は言うコードのビットを確信しています:

Private Sub OpenTabpageTextFolderToolStripMenuItem_Click( _
            ByVal sender As System.Object, ByVal e As System.EventArgs) _
            Handles OpenTabpageTextFolderToolStripMenuItem.Click
  Dim OpenFolder = (RootDrive & "QuickEmailer2\TabTxt")
  Process.Start("explorer.exe", OpenFolder)
  '**I will hang on here while you do your stuff, then I will continue...**
  Call RefreshfromAllTxtFiles()
End Sub
4

2 に答える 2

2

別の解決策: 2 つのボタン/ステップを使用して、プログラムを初めてセットアップします。

  1. ボタン/ステップ #1: セットアップ ファイルを開く
  2. ボタン/ステップ #2: セットアップ ファイルが変更されました...続行!
于 2013-05-23T15:19:58.677 に答える
1

Steve のコメントに沿って、FileSystemWatcher を使用してディレクトリへの変更を監視できます。このようなものから始めることができます:

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Dim fsw As FileSystemWatcher
    fsw = New System.IO.FileSystemWatcher()

    'this is the folder we want to monitor
    fsw.Path = "c:\temp"
    fsw.NotifyFilter = IO.NotifyFilters.Attributes

    AddHandler fsw.Changed, AddressOf IveBeenChanged
    fsw.EnableRaisingEvents = True
End Sub
Private Sub IveBeenChanged(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
    If e.ChangeType = IO.WatcherChangeTypes.Changed Then
        'this displays the file that changed after it is saved
        MessageBox.Show("File " & e.FullPath & " has been modified")

        ' you can call RefreshfromAllTxtFiles() here
    End If
End Sub
于 2013-05-23T15:39:01.760 に答える