Hi All,
I am using a MBS Plugin to do a copy from Source to Destination. I have a text box that has the path to the folder, and another text box that has the drive name in it.
How the code would normally work:
dim source, dest as FolderItem
source=SpecialFolder.Desktop.Child("a") // Copying From
dest=SpecialFolder.Desktop.Child("b") // Copying To
m=new MyFileOperation
m.CopyObject(source, dest, "", m.kFSFileOperationDefaultOptions,1.0)
What i am trying to achieve below. The reason is that my Documents folder will not be in the SpecialFolder.Documents location rendering the SpecialFolder.Documents useless. So i am trying to send the full path to the code so when it runs it knows where the source truly is e.g Volumes/otherdrive/documents
dim source, dest as FolderItem
dim dskpath as string
dim extpath as string
extpath = ExtFolderLocation.Text // This text field has the External Volume Name in it
dskpath = TextField1.Text // This has the Path to the folder e.g. USERS/Test/Desktop/A
source =SpecialFolder.Mount.Child(extpath).Child(dskpath)
dest=SpecialFolder.Desktop.Child("b") // Copying To
m=new MyFileOperation
m.CopyObject(source, dest, "", m.kFSFileOperationDefaultOptions,1.0)
The above fails.
Any help is really really appreciataed
@Christian Schmitz - Any ideas?
I can add a join statement:
[code] dim source, dest as FolderItem
dim dskpath as string
dim extpath as string
dim join as string
extpath = ExtFolderLocation.Text
dskpath = TextField1.Text
join = (extpath+dskpath) //gives exact path
[/code]
but cannot seem to pass it to FolderItem / SpecialFolder
I cannot do:
source=join
dest=SpecialFolder.Desktop.Child("b") // Copying To
as error is expected folder item but got string
I just found the thread, but where is now the problem?
you can use GetFolderItem() with PathTypeNative to build a folderitem from a native path.
In general using paths is a bad idea. Use folder items.
To get one, best ask user to select a location.
Hi Christian,
I have tried to call NativePath and PathTypeNative with no luck. I have also had no luck on trying to get the path to pass in as the source
Submit button that adds path to Textfiled1 which is then fed into the code above
TRY 1
Dim f as FolderItem
f=SelectFolder // Calling the browse folder dialog
If f<> Nil Then
TextField1.Text = f.UnixpathMBS // Pass the folder where i am back to the named textfield
End If
The above provides /User/StoreFolder/A then the Volume name is passed fine in with the Join to give me: MacDrive//User/StoreFolder/A
i=I just cannot get it to pass in the SOURCE command above
TRY 2
Dim f as FolderItem
f=SelectFolder // Calling the browse folder dialog
If f<> Nil Then
TextField1.text = f.PathTypeNative
End If
FAILS: Item doesn’t exist
COPY CODE:
[code] dim source, dest as FolderItem
dim dskpath as string
dim extpath as string
dim join as string
extpath = ExtFolderLocation.Text
dskpath = TextField1.Text
join = (extpath+dskpath)
source=join // HERE IT FAILS
dest=SpecialFolder.Desktop.Child(“b”) // Copying To[/code]
Also Tried:
Dim f As FolderItem
f = GetFolderItem("/home/Jay/", FolderItem.PathTypeShell)
If f.Exists Then
TextField1.Text = f.NativePath
Else
MsgBox("The FolderItem does not exist.")
End if
FAIL: Item doesn’t exist
To All,
No worries i have done it now:
Get Path via Command Button and put it into a TextFiled:
Dim f as FolderItem
f=SelectFolder // Calling the browse folder dialog
If f<> Nil Then
TextField1.Text = f.AbsolutePath
End If
Run MBS Plugin with the path:
[code] dim source, dest as FolderItem
dim dskpath as string
dim dskpath2 as FolderItem
dskpath = TextField1.Text
dskpath2 = GetFolderItem (dskpath)
source=dskpath2
dest=SpecialFolder.Desktop.Child(“b”) // Copying To
/// working code
m=new MyFileOperation
m.CopyObject(source, dest, “”, m.kFSFileOperationDefaultOptions,1.0)[/code]
isn’t it /Users?
f = GetFolderItem("/Users/Jay", FolderItem.PathTypeShell)
also for paths on Mac OS X with Volumes (beside boot volume), use /Volume/<name/