掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
テキストにパスを書くには? (ID:114169)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
36NETさん 答えてくださってどうもありがとうございました。 たくさん答えてくれたから、申し訳ないので お礼です。 私が作ったm3uファイルリストを作る装置です。 TextBoxを一つとButtonを二つForm上に貼り付けてください。 <名前空間にこれを記載してください。> Imports System.IO <これをコピー&ペーストしてください。> Private path As String Dim z As String Dim h As String Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click With FolderBrowserDialog1 .SelectedPath = "" .ShowDialog() End With With SaveFileDialog1 .FileName = "" .Filter = "テキスト|*.txt" .ShowDialog() path = .FileName Shell("cmd.exe /c dir /B /S """ + FolderBrowserDialog1.SelectedPath + """ > """ + SaveFileDialog1.FileName + """") MessageBox.Show("テキスト出力処理完了です。" + vbCrLf + "では、次の作業に進んでください。" + vbCrLf + "テキストファイルを読み込むをクリックしてください。", "メッセージ") End With End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click With OpenFileDialog1 'ダイアログの設定です。 .CheckFileExists = True .RestoreDirectory = True .ReadOnlyChecked = True .ShowReadOnly = True .Filter = _ "すべてのファイル(*.*)|*.*|テキストファイル(*.txt)|*.txt" .FilterIndex = 2 If .ShowDialog = DialogResult.OK Then If System.IO.Path.GetExtension(.FileName) = ".txt" Then Dim sr As New System.IO.StreamReader(.FileName, _ System.Text.Encoding.Default) TextBox1.Text = sr.ReadToEnd '出力するテキストです。(必要ならば変えてください。) sr.Close() Else MessageBox.Show("テキストファイルを指定してください", "エラー") Exit Sub End If End If Dim fileno As Integer Dim s As String fileno = FreeFile() FileOpen(fileno, .FileName, OpenMode.Input) While Not EOF(fileno) s = LineInput(fileno) '処理をさせる Dim nagasa As Integer nagasa = s.LastIndexOf(".") If nagasa > -1 Then 'z = s.Substring(0) z = s Dim nanagasa As Integer nanagasa = z.LastIndexOf("デスクトップ") h = h + z.Substring(nanagasa + 7) + vbCrLf End If End While FileClose(fileno) End With With SaveFileDialog1 .RestoreDirectory = True .OverwritePrompt = True .Filter = _ "m3uファイルリスト|*.m3u" .FilterIndex = 2 If .ShowDialog = DialogResult.OK Then Dim sw As New System.IO.StreamWriter(.FileName, False, _ System.Text.Encoding.Default) sw.Write(h) sw.Close() MessageBox.Show("保存完了しました。", "メッセージ") End If End With End Sub
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.