Bonjour,
je créé un programme simple qui doit me permettre la chose suivante :
sélectionner un fichier source (.txt)
sélectionner un répertoire cible
copier ce fichier source sur tous les fichiers qui sont dans le répertoire sélectionné. En d'autre terme, j'ai dans mon répertoire les fichiers pomme1.txt, pomme2.txt et pomme3.txt, l'appli doit copier le contenu du fichier source dans les trois fichiers pomme.
Pour l'instant j'en suis là:
C'est le plus simple, il me reste maintenant à utiliser filesystem.copyfile pour obtenir mon résultat mais je suis loin d'être certain de savoir l'utiliser!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 Imports System.IO Public Class Form1 Dim myFolder As String Dim mySource As String Private Sub btnSource_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSource.Click srcDialog.Title = "Merci de choisir le fichier source (modèle)" srcDialog.ShowDialog() End Sub Private Sub srcdialog_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles srcDialog.FileOk Dim strm As System.IO.Stream Dim sourcefilepath As String strm = srcDialog.OpenFile sourcefilepath = srcDialog.FileName.ToString tboxSource.Text = sourcefilepath Dim mySource As String mySource = My.Computer.FileSystem.ReadAllText(sourcefilepath) End Sub Private Sub btnSelecttarget_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelecttarget.Click folderDialog.ShowDialog() tboxFolder.Text = folderDialog.SelectedPath End Sub Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click For Each File In folderDialog.SelectedPath Microsoft.VisualBasic.FileIO.FileSystem.CopyFile() Next End Sub End Class
merci d'avance.
(visual studio 10, vb.net 4.0, os cible windows xp)
Partager