Forum > Operating Systems

Unlocking Files

<< < (2/2)

440bx:
@Redenegue,

It would be nice of you to put your code between code tags so it looks like this:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program ProgramName;
To see how I did that, click the "quote" (to quote the message) and you'll see the necessary tags between [ and ].

HTH.

KodeZwerg:
To be honest, on a windows machine I would use the windows api.
I have not checked what RenameFile() does do but this is how I would do:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function MyRenameFile(const OldName, NewName: WideString): Boolean;var  OldNameW, NewNameW: PWideChar;begin  OldNameW := PWideChar(OldName);  NewNameW := PWideChar(NewName);  Result := MoveFileW(OldNameW, NewNameW);end; begin  if MyRenameFile('OldFileName.txt', 'NewFileName.txt') then    WriteLn('File renamed successfully.')  else    WriteLn('Failed to rename file.');end.Extend that snipped with error handling like the link is suggesting.
My example assume that OldFileName.txt does exists and NewFileName.txt not.
That the destination folder exists and your process got write permission.

Navigation

[0] Message Index

[*] Previous page

Go to full version