I am working on a VB.NET / WPF application which will use SQL Compact Edition databases.
The application should allow the user to save and load different versions of the database.
To do this, my intention was to have a standard database name (e.g. myDatabase.sdf) which would be saved in the DataDirectory.
Then the user would have an option to save a version of the current data (calling it what they want e.g. savedDatabase1.sdf) and the application would then take a copy of the database from DataDirectory and save it to another location (e.g. a SavedDatabase folder created in the Windows app data area)
and to load a different version of the database, the application could copy the database from the SavedDatabase folder and overwrite the database in the DataDirectory location.
I can see solutions for overriding the data directory location, but I can't find any code which allows you to retrieve the path of the current data directory folder so it can be used in any file copy activities as described above.
So my question is - How do I programmatically retrieve the full path currently being used as the data directory?
You could save all the data in the same folder as the application:
System.AppDomain.CurrentDomain.BaseDirectory
However if you are not sure you have access to that folder you can always write to the Application Data which is made for this:
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
Then in this location you can create your own application directory and then your sub directories.
simple example would be:
Dim DataPath as String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "/MyApplication/Data/"
connectionString="Data source=|" & DataPath &"myDatabase.sdf;"
Related
We are trying to move some customers data to cloud hosted services and trying to mimic the same way they currently use shared folders on the local network.
We would like to use Digital Oceans since we know their system, but not married to it.
We need the ability to click a folder using File Explorer and open it and see Word and Excel files and be able to click on the document and edit it.
No syscing required. Can be used but not required.
I have setup WinSCH as a client and connected to a Digital Ocean droplet and see and move files, but this does not allow me to edit online files. They must the copied to the local machine and edited and put back or use their folder sync application which sets up a copy of the shared folder on all user computer that need access.
All suggestion would be welcomed.
Thanks
net project as well as a setup project. I also have it so that during installation it asks the users to enter a file location to store their database. the plan is to have an empty .mdf file, with all the tables setup, copied into that folder and I store the folder path in a config file.
this is mainly because I am planning on having multiple separate applications that all need the ability to access the same database. I have it storing the folder path in my config file the only thing I'm having trouble with is
storing the template files I don't know if i should do this in the setup project or main project
how to copy said template files into a new folder
so far I have been unable to find a solution so any help is appreciated
Well here is what I do this in a few of my projects - something that has proven reliable enough for me over the years (which you may or may want to do as well):
I have the program itself create the database files in an initialization routine. First however, it creates the sub folders in which the database files will be stored, if they don't already exist.
To do this, the program just checks if the folder exists and if the database file exists and if they do not, it creates them on the spot:
If Directory.Exists(gSQLDatabasePathName) Then
Else
Directory.CreateDirectory(gSQLDatabasePathName)
End If
If File.Exists(gSQLiteFullDatabaseName) Then
Else
...
I also have the program do some other stuff in the initialization routine, like creating an encryption key to be used when storing / retrieving the data - but that may be more than you need (also, for full disclosure, this has some rare issues that I haven't been able to pin down).
Here too are some addition considerations:
I appreciate you have said that you want to give the user the choice of where to store their database files. However, I would suggest storing them in the standard locations
Where is the correct place to store my application specific data?
and only allowing the users to move them if the really need to (for example if the database needs to be shared over the network) as it will make the support of your app harder if every user has their data stored in different places.
I have found letting the user see in their options/settings windows where their database is stored is a good idea.
Also to encourage them to back those files /directories up.
Also to create automatic backups of several generations for the user.
Hope this helps.
I am working on drupal 7 which has content type that has a filed "file" and the file is uploaded to mysql database.
I would like to find the table where the file is stored as binary BLOB type.
Know the node ID.
Unless you have something special installed that I'm not familiar with, the files themselves aren't stored as binaries/serialized/etc in the DB. The file table (or is it the filr_managed table? I apologize, I'm on my phone and will try to answer more fully when I sit down at a computer) just stores things like the file id (fid) and the path to the file.
As I understand it, storing the files themselves, fully in the DB would lead to some pretty heavy/intense DB call times.
I'm not sure if this is a reason why you expect it to be in the DB, but if you are looking for the files to be accessible following their nodes access, you'll want to look into setting up private file storage outside of the Drupal root directory.
If you have a default configuration, you will find your files in the filesystem, in the following subdirectory of your Drupal installation :
drupal/sites/default/files
If you want to store all the file in the DB, tou can by using a hook on saving file, but it is not recommended for performance reason. Better to acces a file by URL than download it from database.
I have to read the Name and Creation Date/Last Modified Date of all the files that may exist on /product/xyz folder, existing on JBoss Application Server and print the same on JSP.
This folder is being loaded with the fresh files when server is booted. The framework used is Struts 1.2.
Any hints or examples around how to read these information and print on JSP? Thanks!
EDIT :
I understand that it is much easy to read the files from a folder which might be part of my workspace folder. But, this is a different scenario.
Here, the JSP file will be deployed on JBoss application server, in some ABC folder, as part of some EARs. On the same application server, there is some other XYZ location, which will be loaded with the fresh files, when server is booted. I want to read the files existing in that XYZ folder. I Hope the scenario is more clear now.
The code doesn't change whether I try to access the files from my Work Space folders (Rather, which are to be part of EARs) or I may access from the Server File System (Outside the EARs).
The issue could be there in Path Mentioned or the Permission (Read/Write) to the Folder from which the files are being read.
Hey there,
i have a table with a field called "file" full of binary data (The File Itself) how can i open this binary data directly from the database on a click Event for example using c# ?
i dont want to download the file each time to view it .. just view it using the default viewer in the user's OS.
Any Ideas ??
To start off with other than an extremely trivial (throwaway) application I hope that you have setup some layers to abstract the DB access from your UI.
Ultimately your application will have to get the binary object from the DB table and present it as a file to the OS. The applications that come to mind typically want you to pass a filename to them to open them. In essence this means you have to download the file to the local machine with this technique.
The alternative would be to store the files on the filesystem of a server somewhere and place the name/location in your DB (nvarchar). Your application could get the filename/location and pass that to the viewer application.