Click here to Skip to main content
15,887,854 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Over the past few years, I have built a in house excel program to help us with our ordering and management. With the huge growth of the program it has gotten very slow! So I took on the job to create a .net program to get the job done! I have written a lot of the program and so far, so good. I just have one big problem.

My excel program created a new file for each customer (save as .... real simple) and placed into the creators folder that was on a shared cloud folder.

I need to store a lot of info in the new .net program, but it has to be on a customer by customer basis.

I currently have the data I need stored in My.Settings

I need to get this data to a external file, saved in a location that I set

It will then be sent via cloud file share to my other computers where they can open the file and do what is needed with it!

I have to do it this way because sometimes I am in the field with no internet access, and it automatically sends when I receive internet!


I wish I can figure this out, but I am not doing so well.
I need the help from people far smarter than I!

Thank you Code Project!
Posted

Saving a file to any location is actually quite simple.
Most of it you can find in the System.IO Namespace[^].
To check if directories exist or to create new ones you can use System.Directory[^].
For doing the same with files you can use System.File[^] and System.FileStream[^].
To get more familiar with Stream[^]s (such as FileStream) you can Google around. One article I found for you: Basic Instincts: Programming I/O with Streams and VB.NET[^].
When writing to a certain directory you should of course make sure you have sufficient read/write access or an exception will be thrown. FileIOPermission[^] helps in this regard.

When the above methods do not suffice I suggest you read up on Serialization[^] and Serializing Objects.[^].

Hope it helps :)
Good luck!
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 1-Dec-11 19:56pm    
I think legacy serialization is pretty bad. After development of Data Contract, who needs it?
I also think that using Excel is ridiculous -- this is a root problem.
Please see my solution.
--SA
First, if you are going to keep using Excel, I would say, this is not just serious. This approach gives you enough trouble but still keeps you locked with a proprietary, non-free product. I can imagine two opposite approaches: you could use some home-backed storage system (not 3rd-party at all) or the solution based on some RDBMS and client-server (but it still can be free). The solution with Excel is the worse one. It is not designed to be a database, it provides no integration, not support. Do be serious and get to database solution.

You have a good deal of choices. See: http://en.wikipedia.org/wiki/Comparison_of_databases[^].

With VB.NET, you can use ADO.NET. See:
http://en.wikipedia.org/wiki/Ado.net[^],
http://msdn2.microsoft.com/en-us/library/aa286484.aspx[^].

See also this CodeProject article: Using ADO.NET for beginners[^].

Still, you can use files for storing and loading data models with limited volume of data (such as configurations). This approach is good because you don't need any 3rd-party component. The best way is using Data Contract. See:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

I advocate this approach in my past solutions:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^],
deseralize a json string array[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900