Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Using FileDelete on a mapped network-drive

$
0
0

Hi,

 

I've developed a small script that reads several lines from a textfile and then deletes any files matching those lines from a specific folder. It works splendidly on my local disk, but when I try running it on a mapped network-drive it's unable to delete any files.

 

If I run the script on ie. c:\testfolder FileFindFirstFile will return a "handle" if a match is found. If I run the script on M:\testfolder (M: is a mapped drive from our server) it will always return -1.

 

I have full rights to the folder.

 

Any ideas? I realize it's not 'comme il faut' to post a question as your first post on a forum.. but I'm really curious as to why it's not working :-) Also, the code below isn't beautiful.. :-)

 

BR,

Thomas

AutoIt         
#include <File.au3> $file = FileOpenDialog("Choose the file containing the list", "c:\", "Text files (*.txt)"); FileOpen($file, 0); Open the file $folder = FileSelectFolder("Choose the folder containing the files", "") Local $search = FileFindFirstFile($folder & "\*.*"); Make a list of files MsgBox(0, "", $folder) If $search = -1 Then     MsgBox(0, "Error", "No files/directories matched the search pattern");If empty folder, show error     Exit EndIf $counter = 0 For $i = 1 to _FileCountLines($file) ;Loop through the file     $line = FileReadLine($file, $i) ;Get line $i     $filesearch = FileFindFirstFile($line & "*");Search for $line + wildcard     If $filesearch <> -1 Then;Check if match found         FileDelete("*" & $line & "*");Delete any matching files         $counter += 1     Else         ;MsgBox(0, "", "Mappe: " & $folder & " --- Filnavn: " & $line) DEBUG - Can be ignored     EndIf Next If $counter == 0 Then     MsgBox(0, "", "No files were found!");     Else         MsgBox(0, "", "Done! Deleted " & $counter & " unique files.") EndIf FileClose($file)

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>