C#应用程序默认文件夹 [英] C# application default folder

查看:100
本文介绍了C#应用程序默认文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿程序员,



我有这个SQL语法来从我的主计算机更新数据库,但每当我更换计算机时,它只会给我一个错误,无法找到数据库。



有没有办法将该大目录转换为应用程序文件夹的默认目录?



在vb中,要打开数据库文件我只需要使用.. \ DATABASE.mdb



我尝试过:



  backup  数据库 [C:\\Users \\centurion\\Desktop\\AcademiaSK \\AcademiaSK \\ GMS_DB.mdf]  to  disk = ' + destdir +'  with  init,stats = 10 

解决方案

你可以,但你必须从使用SQL服务器到本地数据库,如SqLite或Access - 但即使这样,也不要将数据库放在应用程序文件夹中:我应该在哪里存储我的数据? [ ^ ]解释了原因,并展示了如何更好地使用某个地方。



但是请注意,使用本地数据库意味着您无法与其他人共享:如果您需要这样做,您需要坚持使用SQL服务器,并使您的连接字符串可配置而不是硬编码(无论如何这是一个该死的好主意)。

Hey coders,

I have this SQL syntax to update the database from my main computer, but whenever I change computer, it just gives me the error that the database couldn't be found.

Is there any way to convert that big directory for the default directory of the application's folder?

In vb, to open database files I just needed to use ..\DATABASE.mdb

What I have tried:

backup database [C:\\Users\\centurion\\Desktop\\AcademiaSK\\AcademiaSK\\GMS_DB.mdf] to disk='" + destdir + "'with init,stats=10

解决方案

YOU can, but you have to change from using SQL server to a "local" DB such as SqLite or Access - but even then, don't put the DB in the application folder: Where should I store my data?[^] explains why and shows how to use somewhere better.

But be aware that using a local database means you can't share it with others: if you need to do that, you need to stick with SQL server, and make your connection string configurable rather than hard coded (which is a damn good idea anyway).


这篇关于C#应用程序默认文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆