I try to create music application and now I am in place where after exit from app I want to save somewhere my playlist to when reopen I have my songs in app.
Where application like winamp save that information ?
You can use Isolated storage. This way is quite easy and transparent. Then you can put some sort of XML into your Isolated storage.
Or you can use some sort of in-proc database engines to store your settings. I would recommend using SQL Server Compact as it is quite natural to use it in .NET.
So you have two options. If you have little amount of information to store (playlist only), I would select Isolated Storage. And when your application grows and settings become more complicated you could switch to SQL Server Compact.
You can use the Isolated Storage API to read and write files specific to your application under the user's profile directory. You can store the playlist in a file in any format you choose; using .NET serialization would be quickest, using XML or JSON will let you arbitrarily customise the output.
Take a look at the Isolated Storage feature, see Introduction to Isolated Storage
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MyApplication")
Winamp save the last used playlist in this directory
C:\Users\<username>\AppData\Roaming\Winamp
As for your application, I'd suggest that you use the Isolated Storage API
You could use Application settings which are stored in the user's profile folder.
You can save in a text file or an embedded database like SQLite.
I dont know how winamp does this, but you can do it in many ways. I would create a xml file, or save it in application settings like Darin Dimitrov says it. with the content i need and save it on windows close event. Open it on application start to "restore" application state.
Related
I am trying to make an app that make use of open data.
The data I try to read out is in a CSV format (and is about 40mb big).
I have 2 problems I can't solve.
First I having difficulties to read the file from the web.
I already read on MSDN how to read files asynchrome but it's all about local files. I want to make a list of objects. Each line (except the first line) contains all props for 1 object
Secondly when I finally managed to read the file, is there a way to save it's data and read it somehow the next time? Because 40mb is pretty big to re-download each time you open the app and it takes a lot of time.
I was wondering if it is possible that when I read the the file on the web again, it will only read and at the new lines.
I am a newbie in UWP (c#) applications, so my apologies for the questions.
Thanks in advance.
There are two APIs you can use to download a file. One is HttpClient, described here on MSDN Documentation and in a UWP sample here. This class is usually recommended for smaller files and smaller data, but can easily handler larger files as well. Its disadvantage is, that when the user closes the app, the file will stop downloading.
The alternative is BackgroundDownloader, again here on MSDN and here in UWP samples. This class is usually recommended for downloading larger files and data, as it automatically perfroms the download in the background so the download will continue even when the app is closed.
To store your files, you can use the ApplicationData.Current.LocalFolder. This is a special folder provided to you by the system for storage of application files. You have read/write access to this folder and you can not only store your files here, but even create subfolder structure using UWP StorageFile and StorageFolder APIs. More about this is on MSDN.
In my application, there are about 300 images(.jpg). These images are displayed to the user. I now choose between two options loaded:
Loading of resources in isolated storage.
Working with resource files directly.
Which of these options is better ?
If you are using these images as a static data means these 300 images are kind of dataset for your application then second option Working with resource files directly is fine. There is no need for isolated storage. It is typically used for data that is generated in your app or downloaded from server and you want to use it for future.
Hope it helps you.
I am working on vs2010, .net 4.0 coding in C# WPF Application.
I am making a tool to process some data. It reads files and adds them to a stack, certain processing is done and some data is saved to the disk too. I need to save the current state of project in a file so I can open it again.
I would like to know how can I make a project file. One thing that I can think of is using xml and add all info to it. What other options are there?
Thanks in advance.
Cheers
Add values to the windows registry
Isolated storage
A database
I'd personally opt for the xml file, keep it simple
Is there anyway that I can record sound from a microphone using c# .net
What is the best option if i have to save the audio online in terms of the file occupying storage space.
Any particular format that the file should be saved in for optimum output.
I think you have to use either a small flash application or a silverlight application to do the actual recording. Then you upload the file to your application using a web service or similar.
And mp3 is sort of a standard file format for sound on the web. So I'd go with that.
Have a look at these projects:
http://www.codeproject.com/KB/winsdk/SoundRecord.aspx
http://www.codeproject.com/Articles/67568/Creating-a-Sound-Recorder-in-C-and-Csharp.aspx
http://www.codeproject.com/KB/audio-video/cswavrec.aspx
What is the best option if i have to save the audio online in terms of the file occupying storage space.
May be real media (.rm).
Any particular format that the file should be saved in for optimum output.
Not sure but I think that depends on
your player.
You might also be interested in ffmpeg for converting the media and its c# wrapper library.
I want to retrieve an image from SQL Server to show it in an ASP.NET app. I think that I can write down the image retrieved from SQL Server to a server's folder and show it throw its path. Is there any other better way?
I have the same problem with audio and video files (can I use silverlight to play these audio and video files?)
My worry is that I don't want to store these files (images, audios and videos) on server to show it.
You can write a custom HTTP handler that will take ID of the item you are trying to display on the query string parameter.
This handler will then retrieve the data from SQL Server, and return it just like downloading a file. This post has the steps.
I am not sure about the capability of Silverlight streaming from a "file", you may need to use Silverlight Streaming Service.
Is there a better way? IMHO, yes there is. Store your image file as a file. That's what the filesystem is for, and you don't get involved in fudging around with the database.
I have, in the past, used MySQL to store images and retrieved them with PHP, but that solution got really old really quickly from a maintenance point of view. It comes down to the fact that you are always going to have to store the data in some way, and the most efficient way is also the simplest.
If you must store it in the database, I'd use a generic accessor page (e.g. myImage.aspx) which queries the database and streams the returned blob directly to the browser. Your img tag would probably then need to look like
<img src="/img/myImage.aspx?imgId=123456" <other tag data> />
If you use SQL Server 2008, then I believe you can store these objects as a FILESTREAM, and you can then retrieve the path to the files on the file system. You should be able to arrange for that path to be mapped via IIS, and thus it should be practical to turn it into a URL.
Your image source can be
<img src="blah.aspx?id=123" />
In blah.aspx, retrieve the image data from the db and use Response.BinaryWrite to send to the browser, with the appropriate content type set.
HI all, I guess the solution for this is present in below links:
http://www.codeproject.com/KB/aspnet/asp_net_and_mysql.aspx
http://www.codeproject.com/KB/aspnet/image_asp.aspx
This solution in for mysql database and also could be suitably modified to work with mssql database as well.