Hi,
I have a canvas in my window which accepts file drops. Can anyone please point me in the right direction how I get the name of the dropped file?
The extension is not necessary - I just need to find out the name of the file so that I can access it later on.
DragItem allows you to access the dropped object in few different ways, one of which being the FolderItem. You can then use the FolderItem properties to get the information you seek.
A file extension does not always have 3 characters
Public Function GetFileName(Extends f As folderitem) as String
dim name as String
dim parts(), filename() as string
parts = f.NativePath.Split( "/" )
filename = f.NativePath.Split( "." )
name = parts(UBound(parts)).Replace("." + filename(UBound(filename)), "")
Return name
End Function
[quote=301517:@Axel Schneider]A file extension does not always have 3 characters
Public Function GetFileName(Extends f As folderitem) as String
dim name as String
dim parts(), filename() as string
parts = f.NativePath.Split( "/" )
filename = f.NativePath.Split( "." )
name = parts(UBound(parts)).Replace("." + filename(UBound(filename)), "")
Return name
End Function
[/quote]
the problem is if the extension is .MPEG4 and if the application has .MPEG4 in the middle of it, then you will not remove the right .MPEG4.
public function FilenameWithoutExtension(extends fItem as FolderItem) as String
dim arsSplitNameParts() as String = fItem.name.split(".")
call arsSplitNameParts.pop
return Join(arsSplitNameParts, ".")
end function
If that works with no modification someone owes me a drink.
public function FilenameWithoutExtension(extends fItem as FolderItem) as String
dim arsSplitNameParts() as String = fItem.name.split(".")
if arsSplitNameParts.uBound() > 0 then
call arsSplitNameParts.pop
end if
return Join(arsSplitNameParts, ".")
end function