* * *

Author Topic: Need help renaming a file via a samba share  (Read 258 times)

glubbish

  • New member
  • *
  • Posts: 10
Need help renaming a file via a samba share
« on: October 14, 2018, 09:16:01 am »
Hi,
Running on windows, accessing ubuntu files via a samba share. The share is connected as the file owner.
I would like to be able to rename the file but so far no luck.
The old and new file names are in a stringgrid and my attempt is using:
Code: Pascal  [Select]
  1. if not renamefile(Display.Cells[0,i],Display.Cells[1,i]) then showmessage('Rename Failed');
  2.  

The contents of the cells are like:
\\machinename\sharename\directory\file.txt

I have tried values like
\\machinename\sharename\directory\file.txt, \\machinename\sharename\directory\file2.txt
\\machinename\sharename\directory\file.txt, file2.txt
but still get rename failed showing.

any ideas?

Thanks Derek

fred

  • Full Member
  • ***
  • Posts: 112
Re: Need help renaming a file via a samba share
« Reply #1 on: October 14, 2018, 09:44:35 am »
I do not know samba but perhaps you can get the error message?
Code: Pascal  [Select]
  1. ShowMessage(SysErrorMessage(GetLastOSError));
Started with OmegaSoft Pascal on OS-9/68k , now Lazarus 1.8.4 / FPC 3.0.4 on Windows 7

glubbish

  • New member
  • *
  • Posts: 10
Re: Need help renaming a file via a samba share
« Reply #2 on: October 14, 2018, 10:30:17 am »
Oddly enough that gives "The operation completed successfully"

ASerge

  • Hero Member
  • *****
  • Posts: 945
Re: Need help renaming a file via a samba share
« Reply #3 on: October 14, 2018, 10:39:33 am »
The old and new file names are in a stringgrid and my attempt is using:
Code: Pascal  [Select]
  1. if not renamefile(Display.Cells[0,i],Display.Cells[1,i]) then showmessage('Rename Failed');
  2.  
any ideas?
Reproduced without a StringGrid (just a string constant)? Is the operation performed outside the program (cmd, explorer)? RenameFile is Sysutils.RenameFile?

glubbish

  • New member
  • *
  • Posts: 10
Re: Need help renaming a file via a samba share
« Reply #4 on: October 14, 2018, 10:43:40 am »
my own stupid fault.
The kind of files were varied and the algorithms complex.
I included a variable in the name I should not have.
Sorry to waste time.

fred

  • Full Member
  • ***
  • Posts: 112
Re: Need help renaming a file via a samba share
« Reply #5 on: October 14, 2018, 12:03:16 pm »
No problem, i'm glad you found it and it works.
Started with OmegaSoft Pascal on OS-9/68k , now Lazarus 1.8.4 / FPC 3.0.4 on Windows 7

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus