Questo topic e' stato chiuso dal moderatore.
24/02/09 20:16
sps84
Imports System Imports System.IO Public Class Form1 Private Sub scrivi(ByVal line As String) Dim filemancante As System.IO.StreamWriter If My.Computer.FileSystem.FileExists("File_mancante.txt") Then filemancante = My.Computer.FileSystem.OpenTextFileWriter(Application.StartupPath & "\File_mancante.txt", True) filemancante.WriteLine(line) filemancante.Close() Else End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Using sr As StreamReader = New StreamReader(Application.StartupPath & "\lista.txt") Dim line As String ' Read and display the lines from the file until the end ' of the file is reached. 'System.IO.File.Create(Application.StartupPath & "\Foto_mancanti.txt") Do line = sr.ReadLine() If line = "" Then Exit Do End If 'MsgBox("File: " & line & ".jpg") If My.Computer.FileSystem.FileExists(line & ".jpg") Then My.Computer.FileSystem.CopyFile(line & ".jpg", Application.StartupPath & "\ file_da_lista \" & line & ".jpg") Else MsgBox("Manca la foto del seguente articolo: " & line & ".jpg") 'scrivi(line) End If Loop Until line Is Nothing MsgBox("Fine Spostamento") End Using Catch Ex As Exception Let the user know what went wrong. MsgBox("Atenzione il file non può essere letto!!") MsgBox(Ex.Message) End Try End Sub
Praticamente il programma sposta delle immagini da un cartella ad un'altra in base a dei nomi contenuti in un file txt. Fino a qui funziona tutto, quando non trova una foto da spostare comapre un meaggio col nome del file, a quel punto dovrebbe scriverlo in un file txt ma ciò non avviene...Pero' il file Foto_mancanti.txt è solo vuoto... Portate pazienza pe come ho postato il codice, la prima parte lìho esclusa perchè mi serviva urgentemente...
aaa