Recent

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

glubbish

  • New Member
  • *
  • Posts: 46
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: 201
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));

glubbish

  • New Member
  • *
  • Posts: 46
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: 2223
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: 46
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: 201
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.

 

TinyPortal © 2005-2018