Invalid filepath for windows phone?

Category: windows phone development

Question

The Thinker on Wed, 04 Feb 2015 19:15:22


In my code below the filepath is invalid or else the upload would go without a hitch. Does windows phone 8.1 Silverlight have a full file path system similar to windows desktop applications? (i.e C:\Folder\File.txt). Note: this can include file:\\Folder\File.txt if it would work.

  Dim currentFolder As StorageFolder = Windows.Storage.ApplicationData.Current.LocalFolder
            Dim stor As StorageFile = Await currentFolder.GetFileAsync("QADB.sdf")
            Await stor.RenameAsync("QADB.txt")
            Dim publicFolder As ICloudDirectoryEntry = tempbox.GetRoot
            Dim fileName As String = "Data\\QADB.txt"
            Dim parentPath As String = ApplicationData.Current.LocalFolder.Path
            Dim filePath As String = Path.Combine(parentPath, fileName)
            tempbox.UploadFile(filePath, publicFolder)
            tempbox.Close()


Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr

Replies

Rob Caplan [MSFT] on Wed, 04 Feb 2015 21:54:02


You're saving it to <LocalFolder>\QADB.txt but trying to read it from <LocalFolder>\Data\QADB.txt.

Windows Phone apps have direct access only their app data and install directories, but they can address those directories by path.

The Thinker on Wed, 04 Feb 2015 23:33:23


You're saving it to <LocalFolder>\QADB.txt but trying to read it from <LocalFolder>\Data\QADB.txt.

Windows Phone apps have direct access only their app data and install directories, but they can address those directories by path.

Its still not working, I change the filename variable to QADB.txt and I do not know why it works in a windows form project and not in windows phone (the code is almost identical except for the path parts and async methods). I can verify that all operations up to upload file execute. I really wish their was an async method for the uploadfile function above. Can I make the function run in the background or do think that running it async has nothing to do with it?

mSpot Inc on Thu, 05 Feb 2015 01:35:20


You left out a lot of pertinent information. Based on the appearance of "ICloudDirectoryEntry", I guess you're using SharpBox, a 3rd party library. A far as I could tell, development for the phone stopped at Windows Phone 7. The SDK for WP7 didn't even have API for StorageFile/StorageFolder, so indeed you might not be providing the path it expects.

I suggest that you download and run the SharpBox source code instead of using the binary library, and debug it at the source level.

The Thinker on Mon, 09 Feb 2015 15:10:21


You left out a lot of pertinent information. Based on the appearance of "ICloudDirectoryEntry", I guess you're using SharpBox, a 3rd party library. A far as I could tell, development for the phone stopped at Windows Phone 7. The SDK for WP7 didn't even have API for StorageFile/StorageFolder, so indeed you might not be providing the path it expects.

I suggest that you download and run the SharpBox source code instead of using the binary library, and debug it at the source level.


Sorry, for the late response, I was working on another project and was distracted (Not to mention the weekend). That's what I thought. I could try and rebuild the library from source code with the special path system for windows phone 8 built into it. I know it works or at least the upload part. I think I will do your suggestion though or I could develop a asp.net web service or find one that uploads to dropbox. If you have any suggestions as to a SOAP or WCF web service that might have a SOAP endpoint please post them and I will avoid sharpbox unless you suggest not to.

Rob Caplan [MSFT] on Tue, 10 Feb 2015 17:35:45


For modern web services you should look for a REST endpoint. Most (all?) modern web service stacks should support this.

The Thinker on Mon, 16 Feb 2015 02:34:41


Thanks for all the answers but mSpot helped me out. I think I need to modify the main source code to support windows phone 8.1 unless their is an alterative for SharpBox.

mSpot Inc on Mon, 16 Feb 2015 04:20:16


There is another library called DropNet (https://github.com/DropNet/DropNet), although like SharpBox it also wasn't developed further than WP7. REST API is truly the best long term solution.