Am I an idiot? There’s gotta be a better way to do this.

I'm just trying to get the filename of a local file that is stored in my viewmodel as a Uri. My code seems really hacky, but I'm having a hard time coming up with a better solution. Anyways, here's my code:

 var uriPath = uri.LocalPath; var localFolder = ApplicationData.Current.LocalFolder.Path + "\\"; var fileName = uriPath.Replace(localFolder, ""); 

Please tell me there is an easier way to get the filename…

by ducttape36 via /r/csharp

Leave a Reply