tdxev Posted January 11, 2010 Report Posted January 11, 2010 Încerc sa listez toate directoarele de pe hard disk ?i prima data am o problema cu dosarul "System Volume Information", am reu?it s? trec peste acest? problem? dar acum am alata. Nu poate citi un dosar de genul " ^ " (care con?ine spatii si la început ?i la sfîr?it).Exemplu de structura de directoare la care primesc eroarea:root\root\ ^ \root\ ^ \dir\root\dir\Eroarea este primita în momentul în care încearc? citirea subdirectoarelor din directorul " ^ "Forma con?ine :type | name----------------------buton | Button1_Clicklistbox | DriveListlistbox | DirListPublic Class Form1 Private Sub FindFile(ByVal path As String) For Each DirName As String In My.Computer.FileSystem.GetDirectories(path, FileIO.SearchOption.SearchTopLevelOnly, "*") If Not DirName.Contains("System Volume Information") Then DirList.Items.Add(DirName) FindFile(DirName) End If Next End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim drvList As System.IO.DriveInfo() drvList = System.IO.DriveInfo.GetDrives For Each DrvInfo As System.IO.DriveInfo In drvList If DrvInfo.DriveType = IO.DriveType.Fixed Then DriveList.Items.Add(DrvInfo.Name) FindFile(DrvInfo.Name) End If Next End SubEnd Class Quote
CyberWolf08 Posted January 11, 2010 Report Posted January 11, 2010 Private Sub FindFile(ByVal path As String) Try For Each DirName As String In My.Computer.FileSystem.GetDirectories(path, FileIO.SearchOption.SearchTopLevelOnly, "*") If Not DirName.Contains("System Volume Information") Then DirList.Items.Add(DirName) FindFile(DirName) End If Next Catch ex As Exception Debug.Print(ex.Message) End TryEnd SubAr trebui sa rezolve problema cu citirea din locatii nepermise(\$RECYCLE.BIN,\Config.Msi si multe altele mai ales sub Vista/7)In legatura cu problema ta cu fisierele de genu " ^ " sa stii ca fisiere asa nu exista. Windowsul redenumeste automat la "^"(fara spatii) Quote
tdxev Posted January 11, 2010 Author Report Posted January 11, 2010 "try" Ma scapa doar de eroare ... dar tot nu pot citi continutul dosarului..Sub XP :-pot creea dosare " ^ " fara sa inlocuiasca nici un spatiu-iar in cazul fisierelor taie decat spatiul de la sfarsit devenind " ^" Eu sunt nou in vb si credeam ca am gresit ceva sau poate nu fac ceva bine dar vad ca mai sunt si alte probleme .. cred ca trec inapoi pe delphi. Quote
CyberWolf08 Posted January 11, 2010 Report Posted January 11, 2010 Care XP? Sub SP3 tocmai am incercat si imi redenumeste atat folderele cat si fisierele la "^" Quote
tdxev Posted January 12, 2010 Author Report Posted January 12, 2010 xp professional version 2002 service pack 3 NTFS Quote
CyberWolf08 Posted January 12, 2010 Report Posted January 12, 2010 Mie tot imi redenumeste la "^" Am apelat FindFile("C:\^") ca sa imi dea doar folderul de care am nevoie Quote
tdxev Posted January 15, 2010 Author Report Posted January 15, 2010 Da ai dreptate acum am creat si eu un director in Explorer si sterge spatiile.Foarte rar folosesc explorer eu lucrez mai mult cu TC UP (Total Commander), de aceea puteam creea aceste directoare cu spatii.Pana la urma am folosit Try ca nu aveam ce face Quote