I am making an app using Visual studio for the windows 8 platform. I need to be able to save some data which includes two strings and an array.
I have been searching online about how to save data, many posts have said that I need to save the data in a DLL. However none of these posts cover how you can do it using C#.
Does anyone know how I can do this in C#? The has to be saved permanently, so when the app is opened up again, I can access and use that data. Or if the machine is restarted, the app can still access its old data.
To create DLLs, you have to set up your Visual Studio
https://msdn.microsoft.com/en-us/library/ms164704.aspx
Related
I am using Microsoft's App Center with a .NET Core 3 WPF app. I do not want to store my app center key in the source code directly, as my software is open source. I'm using Visual Studio, and I've googled around on ways to not store my API key in the source code directly. I know you should not store them there, but when it comes to build time, I need to have the API key accessible as a string to the code so it can pass it off to a method call.
I am not extremely worried about someone running my app through a disassembler, but I would like to thwart the casual people who might want to poke around more than they should. In Visual Studio/c#, I can't seem to find any way to do something like this. Like a #ReadFromFile(filepath) directive or something that could read the contents of a file and substitute it into the document at compile time.
Does anyone know of a way to do something like this? I have seen many answers about "how you should just never do it", but I don't really have the resources to do what a lot of them do. I just have a fairly simple application that's open source and uses an API key.
I think there are 3 possible solutions:
Put the key in a file that your application will read at startup and exclude this file from version control.
a) Put your key in the Environment Variables. This is the way you would do it for a cloud application.
(but because you need it for a desktop application every program on your PC can read them)
b) If you are working only on windows put it in the windows registry. (other programs can reed this too)
Call your Program with the key as a parameter. You can create a batch/powershell (on windows) or bash (on linux) script or create a desktop shortcut so that you don't have to start you application over the terminal all the time.
(Additionaly you could also encrypt the key and ask the user for a password on startup. So even if other applications can read your key they have only the encrypted data.)
I have recently taken a project for a client which involves working with their Microsoft Access database programmatically with C# in Visual Studio 2015/2017.
The database opens in my 64-bit version of Microsoft Access 2010 just fine, and I can use/alter all tables/queries perfectly fine. However, when trying to open this .accdb database in Visual Studio, I am getting the dreaded "Unrecognized database format". Now, I do have the Microsoft Office Access database engine for 2007 and 2010 installed, and I am able to open/work with other databases created in Access.
I believe the database was created in Access 2007, as when I open it up, the title of the window contains "(Access 2007 - 2010)", so I'm not sure if that would cause the error or not?
One interesting thing I found was, because I do not need every table in the database, I copied one by one the tables I need into a new database file and checked if I could open this new Access database in Visual Studio. Out of 6 tables that I needed, the last one I needed caused the file to become "unrecognizable" inside Visual Studio.
Why? I have no idea. The table is just like any other, contains lots of columns which either have text, numbers or dates.
My question is, has anybody had a similar experience with this? Could it be the fact that it was made from Access 2007? Why would copying and pasting to a new database then cause that database to be corrupt?
Thanks a lot.
There's a difference in the formats. The older format (..2007) is MDB and the later ones (2010...) are ACCDB. If you used any features only available in ACCDB, like attachments, you cannot convert back to MDB and neither will ANY current Microsoft tool other than Access open it. Strange but true.
Painful is to exclude those tables or forms that use the new features and then do the conversion.....sigh.....
I have a very simple use case.
1) I have 4 config files which are needed for the application to start.
When I publish my application these files should be exported by default along with it. How can I do this ? Where should the files be stored so that they are available when the pplication is installed?
The users of this application should be able to edit and access these files.
I have seen the option of saving it using string source = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
I have tried adding these as resources, but these files need to be editable, hence cannot be in exe.(Reference is this question)
Please comment if you need additional information.
If you're building the installer in Visual Studio, you can add those files as Content and it should be automatically included in the installer when it's built.
You create installers in Visual Studio by adding a Setup Project to the solution.
Link to tutorial on MSDN: http://msdn.microsoft.com/en-us/library/vstudio/19x10e5c(v=vs.100).aspx
I recall it should automatically add all Content items automatically, but I'm a bit rusty. Here's more detail on how to add items to your installer, including desktop shortcuts and such:
http://msdn.microsoft.com/en-us/library/vstudio/z11b431t(v=vs.100).aspx
Good luck!
There are meny ways to do whay you want to do. the main question is why do you want to do it?
if you have a normal program for personal use you can simply link it to the needed file, meaning using the file without actual knowledge that it's there.
if it's for a task then you can zip them together, that way you'll know they are together, without adding them as resource.
for other kind of use, or if you have to add them as resources, just add them like shown here
for more reading on what do you need and how to do it i have here linked vs. Embeded resources
good luck
I'm working with a C# and Linq to SQL Winforms app and needed to integrate backup and restores through the program. I used SMO and got it working pretty smoothly. The issue, however, is that the app is deployed using ClickOnce, which I like very much - but since I had to include the dll's the download size jumped from 3mb => 15mb. I know they've only got to download it once, but it also sucks for me as Visual Studio 2010 seems to upload the dll's every time and that takes a while on AT&T broadband (eh).
So, anyone have any suggestion on how I can work out an effective backup/restore solution without using SMO objects?
You can just fire plain ol'sql at the box via ado commands
You can use stored procedures to do backup and restore in lieu of SMO. There are a number of samples available on the web, including this one.
Just a quick question:
I'm in the finalizing state of my current C# project, and I'd like to send a version out to people that has 90% of the features initially requested, but it'll be a version of the software that will do all they need - they need the software as soon as possible, basically.
Therefore I'm going to be using the online install option in VS2008 that will use updating to add the final few features, as well as additional things, later. What I'm wondering is the following:
The program will come packaged with a .mdf file. When I create a new version of the program however, I don't want to change all of the data that has been added to the database already. My question is how do I go about doing this?
Thanks!
How are you planning to distribute the update? An installer will have flags indicating when a file should be replaced. (Date, version etc)
One-Click installation has the ability to check for changes on program startup.