sb1920alk Posted May 12, 2009 Share Posted May 12, 2009 If I use FileCopy to copy a file from a CD, they're ending up as Read Only on the hard drive, and then I have to go back through and take off the Read Only attribute with FileSetAttrib. If I drag and drop the file manually, the result is not Read Only. Am I missing something? Is there an easier way? I don't want copied files to be Read Only after they're on the hard drive. Thanks, Link to comment Share on other sites More sharing options...
Authenticity Posted May 12, 2009 Share Posted May 12, 2009 Perhaps, it's because you're using FileCopy? Try to use FileOpen(), FileRead() and FileWrite(), so you control the creation of the file and it's attribute and write using buffer which may be necessary. Link to comment Share on other sites More sharing options...
sb1920alk Posted May 12, 2009 Author Share Posted May 12, 2009 Perhaps, it's because you're using FileCopy? Try to use FileOpen(), FileRead() and FileWrite(), so you control the creation of the file and it's attribute and write using buffer which may be necessary.I thought FileOpen, FileRead and FileWrite were only for txt files? I don't see how they would be helpful in this situation. Link to comment Share on other sites More sharing options...
Authenticity Posted May 12, 2009 Share Posted May 12, 2009 You can read in binary form. Read the help file. If no, use _WinAPI_CreateFile(), _WinAPI_ReadFile() and _WinAPI_WriteFile(). This way you have more control on the streaming but more code to write. Link to comment Share on other sites More sharing options...
sb1920alk Posted May 12, 2009 Author Share Posted May 12, 2009 You can read in binary form. Read the help file. If no, use _WinAPI_CreateFile(), _WinAPI_ReadFile() and _WinAPI_WriteFile(). This way you have more control on the streaming but more code to write.I have read the help file. I wasn't sure what the mode options other than 0, 1, and 2 were for. I thought it was something like case sensitivity. In any case, I don't see how this is simpler than using FileCopy and FileSetAttrib. I think that the fact that the files are on a CD somehow forces them to be read only because the CD is read only. Link to comment Share on other sites More sharing options...
rajeshontheweb Posted May 12, 2009 Share Posted May 12, 2009 (edited) did u try Windows API CopyFile Functionor could use a seperate function _FileCopy which will contain the code for copying the file and then resetting the attribute as well. Edited May 12, 2009 by rajeshontheweb Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet Link to comment Share on other sites More sharing options...
rudi Posted May 12, 2009 Share Posted May 12, 2009 Hi. robocopy.exe vers. 026 (included in robocopygui -> google) has a switch to modify flags as needed, and it's exit code will tell you what happened very nicely. Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
GEOSoft Posted May 12, 2009 Share Posted May 12, 2009 Did you try anything like what Authenticity suggested? $File = "CD\File\Path" $nFile = "Hard\drive\path" $hIn = FileOpen($File, 16) $hOut = FileOpen($nFile, 18) FileWrite($hOut, FileRead($hIn)) FileClose($hIn) FileClose($hOut) George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
sb1920alk Posted May 15, 2009 Author Share Posted May 15, 2009 Did you try anything like what Authenticity suggested? $File = "CD\File\Path" $nFile = "Hard\drive\path" $hIn = FileOpen($File, 16) $hOut = FileOpen($nFile, 18) FileWrite($hOut, FileRead($hIn)) FileClose($hIn) FileClose($hOut)...haven't had a chance yet. I only needed a dozen or so files and FileCopy/FileSetAttrib was good enough for now. At some point I may need to move many files in many folders from a CD to a Hard Drive, and will probably look in to it further then. Unfortunately, I have little time to prepare right now. BTW, I couldn't figure out how to set attributes on a folder. Is there a function for that or would you just call cacls or xcalcs in a RunWait and be done with it? Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted May 15, 2009 Share Posted May 15, 2009 BTW, I couldn't figure out how to set attributes on a folder.According to the helpfile for FileSetAttrib:file pattern File(s) to change, e.g. C:\*.au3, C:\DirYou get it? .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
sb1920alk Posted May 15, 2009 Author Share Posted May 15, 2009 According to the helpfile for FileSetAttrib:You get it? Maybe I'm missing something obvious. I made a new folder in my script folder and ran: FileSetAttrib(@scriptdir & "\New Folder","-R",1) and didn't see any change to the Read Only checkbox of the folder's properties. It's a box-in-a-box...not a check, not empty. The 1 indeed changes all the files in the folder. I thought "-R" would clear the Read Only box on the folder and "+R" would check the box. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted May 15, 2009 Share Posted May 15, 2009 Maybe I'm missing something obvious. I made a new folder in my script folder and ran: FileSetAttrib(@scriptdir & "\New Folder","-R",1) and didn't see any change to the Read Only checkbox of the folder's properties. It's a box-in-a-box...not a check, not empty. The 1 indeed changes all the files in the folder. I thought "-R" would clear the Read Only box on the folder and "+R" would check the box.The "box-in-a-box" is there no matter if it's "Read Only" or not. Try changing the properties manually by rightklicking the file, exit the dialog and then check the properties again and you will se the "box in a box".... Always the box... Just test it with FileGetAttrib() if you don't trust Explorer. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
sb1920alk Posted May 15, 2009 Author Share Posted May 15, 2009 The "box-in-a-box" is there no matter if it's "Read Only" or not. Try changing the properties manually by rightklicking the file, exit the dialog and then check the properties again and you will se the "box in a box".... Always the box... Just test it with FileGetAttrib() if you don't trust Explorer.You're right. Thanks for pointing that out. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now