Copying a file...selected by user

Hi, I know that this is probably easy for you techies buit all I want to do is this.

User selects file…

I then alter the file…

Customer the selects were to put the changed file…

Save the file using a different name

Simple write… have been trying for ages to get it to work using CHILD but no matter what I try no luck

Can get the file and edit it but is writing it back to were the user wants it.

Help…(please keep it simple)

When you say you alter the file, what do you mean. Are you taking about the name of the file or the contents. If it is the contents of the file, what type of file is it? Text, graphics? You can open the file by presenting a file open dialog:

Var f As FolderItem = Folderitem.ShowOpenFileDialog( FileTypeGroup1.Jpeg )
If f <> Nil Then
   // The user has selected a file to open / modify
   // Make your changes here.
   Var s as FolderItem
   s = FolderItem.ShowSaveFileDialog( "jpg", "DefaultName.jpg" )
   If s <> Nil Then
      // Save your new contents.
   end if
end if

Thanks for your prompt reply.
Sorry made a mistake in my explanation…(Get late here…)

The files are binary and the name has to be changed but he file has no extension just the name. so the default selection will be “???”
The saved filename will have an extention of .chd

Buit the folderitem and name is used by a routine so the folderitem will need to be passed to it and it will save the file.

Sorry again for not making oit clear what i need

Any further info just ask.


File selected

destination selected filename given

Filename passed to routine which uses folderitem to write changed to save file.

Which dialog do you present to the user to choose where to save? SaveFileDialog or SelectFolderDialog?


Sorry am getting tired and did not explain properly.

I need to use the original filename but it will be altered.
thats why am having a problem I can get the file and cannot change the name and create the folderitem
to use in the routine.

Needs a folderitem passed to it with the new name.

If the source file does not have an extension then the new name would be:

DestName = Source.Name + “.CHD”
DestFolderItem = SelectedFolder.child( DestName )

Source.CopyFileTo( DestFolderItem )

It should be something like

var newfilename as string = + ".chd"
var newfile as folderitem = selectedfolder.child(newfilename)

where does that go bad?

Ian & Tim
Please forgive me but will need to try it tomorrow as am really tired so will let you know as soon as I can
get myself awake.

Thanks to all


No problem 1:30am here :wink:

Just realised is 1:53 here so must be in the same time zone Ian.


I’m in the UK.

Hi Ian,

Am also in UK (Devon).

Thank you and all for the help have used the info given and now works fine.
Help off askinf for help here as thought it was me not getting the code write but you people are heros.

Thanks once again for your help


I’m up Oxford way. Glad it solved the problem.

JUst to thanks again after using the method I learn more about folder items so managed to sort
out another problem.


Ian (Bideford)

1 Like