UWP (C#) - Where and how should files be saved and accessed? - c#

Where and how should files be saved and accessed, e.g. Images downloaded by my application and then visible from my app.
Scenario:
I give my app URLs to images placed online on random places. The app downloads them and saves them "somewhere". Saved images are used as news article images in my app. Files should be accessible in the Photos app.

Save your data to ApplicationData.LocalFolder, it is intended for exactly this. But your data will not be visible outside your app. If you want to make some photos accessible in the Photos app, you need to save them to the Windows.Storage.KnownFolders.PicturesLibrary folder.

Related

Have a user upload an image to the Android Resources/drawable folder

I need the user to be able to upload an image, and then have the image be able to be accessed later for drawing it. I only know how to show an image in the Android Resources/drawable folder. I don't think it is possible for a user to upload an image there, so is there another place they can upload it, and then have the image to be used? I don't know how to have the user to be able to upload it either.
I only know how to show an image with the xaml code <Image Source="image.png"/>, where image.png is in the Android Resources/drawable folder
Since Resources contained in out raw directory of our project will be packaged inside our APK and will not be writeable at runtime.
So I highly recommend that you use Internal or External Data Storage to store your images and text file.
For more details, you can check: https://learn.microsoft.com/en-us/xamarin/android/platform/files/
And at the bottom of this page:External storage, there is a example which function is to save text file in External storage, it should be helpful for you.
The sample link is here: https://github.com/xamarin/monodroid-samples/tree/master/LocalFiles
If you want to choose Photos and Video, you can use MediaPlugin of jamesmontemagno. Of course , you can achieve this function yourself.

File saving issue Windows phone 8.1

I am facing the following issue while performing the save operation on a windows 8.1 phone
a. Let us assume there is a a file named test1.doc is downloaded to a default location in the sdcard. SDCARD - Testfolder
b. We try to edit/open the file using the office 365 present in the phone and try to save it. It does not save it in the same location i.e. TestFolder.
c. It prompts the user to save in the file in the default folder present in phone for eg in the above case since it is a .doc it saves in Documents folder.
Based on the file extension, it will try to save them in the respective default location i.e. mp3 will be saved under music, .jpg or png will be in picture, .mp4 under videos and .doc,.xls,.txt, ppt under documents.
Pl. refer to the below link
https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn639127.aspx
d. And during save it also modifies the file name by appending (1) to the file. User is also given the option to modify the file name before saving.
Where on the tab and desktop it is allowing us to do the save on the same location.
I would like to know if it is a know limitation on the windows phone or any thing needs to be done to make the file save in the same location. Any input on this will be of great help.
That is the platform norm (I am not calling it as "limitation"). Every app has access to its own IsolatedStorage and media libraries depending on the access requested in manifest.

Windows Phone 8.0 - Access phone's local storage

Is there any API that enables me to access the phone's local storage files and folders ? I want to implement a file picker that displays the folders and files hierarchy just like they are in folder explorer:
Microsoft has released a free app called "Files" that does exactly what I want and more. Is it a special case or its possible for any developer?
Note: Im programming a WP8.0 app and not WP8.1. File Picker sample won't work for me! :)
There is no API in WP8 to list all the files in storage. In WP8 you can only access Audio and image files.
For more details refer this.

Display thumbnails for images in articles

So I have this website where users can post articles, each article containing at least one photo. What I want to do is when I display the list of articles on the website I want to also show a thumbnail next to the articles name.
Here comes the tricky part: the images are not hosted on my server, are simply links hosted on some image-hosting website. Another problem is that I don't know where the images appear in the post (they could be at the beginning, at the end or in the middle of the article).
What would be the best approach to create a thumbnail system in this case?
I was thinking maybe I could do this: every time an article is posted or edited and stored into the database I could scan the entire articles for images links and store the first link in a separate value in the database (this could be kind of slow though).
Also once I have those values stored and I have to display a thumbnail the only way to do so will be by showing the full image resized to the thumbnail size (that means the user has to download multiple full-size images to see the articles list with thumbnails).
Is there any better approach? (you can see the technologies used in the tags)
Create a thumbnails task that runs in the background after an article has been published.
Find image tags in the article HTML using regular expression.
Get those images and create and thumbnail that you save locally in a folder in your server.
Protect that folder/location against hotlinking.
Use those local pictures as thumbnails
Use HtmlAgilityPack as a starter to get to the images from the image host.
Use an ASP.NET handler to generate the thumbnails. That way, you won't have to store anything locally, the thumbnails images will only exist in memory, making hotlinking impossible

how to manage image file in c# for asp.net mvc web-application

How to manage user picture in c# for my web application
i want all images as
1.png 2.png 3.png if user upload GIF and jpeg that it is convert to .png
how i can do this.
Phil Haack just wrote about Uploading a file (or files) with ASP.NET MVC.
This will give you a good starting place with your image upload requirements.
Once you've obtained the image from the user you can name it anything you like before saving. You could store all images together and link the user to the image via a database entry or you could create a user image folder and store the image in there.
There's a huge variety of ways you can accomplish your goal so these are just a couple of sugestions to help you along the way.

Categories