I have a WPF application. The client's database file is a .SQLite file and is created during the first run of the application. Also some excel files are also generated during run time. All these files are stored in AppData instead of the root directory.
I have given the following path for the database but it still creates the file in AppData folder.
System.IO.Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location) + #"\NuEattendance_Faculty.sqlite"
Please help!!!
My query has been resolved. The application couldn't get the required permission and hence it created the files in AppData folder
Related
I want to run a notebook that uses many header files defined in the directory. So basically I want to upload the entire directory to Google Colab so that I can run the notebook. But I am unable to find any such options and only able to upload files not complete folders. So can someone tell me how to upload entire directory to google colab?
I suggest you not to upload them just in Colab, since when you're restarting the runtime you will lose them (just need to re-upload them, but it can be an issue with slow connections).
I suggest you to use the google.colab package to manage files and folders in Colab. Just upload everything you need to your google drive, then import:
from google.colab import drive
drive.mount('/content/gdrive')
In this way, you just need to login to your google account through google authentication API, and you can use files/folders as if they were uploaded on Colab.
EDIT May 2022:
As pointed out in the comments, using Google Drive as storage for a large number of files to train a model is painfully slow, as described here: Google Colab is very slow compared to my PC. The better solution in this case is to zip the files, upload them to colab and then unzip them using
!unzip file.zip
More unzip options here: https://linux.die.net/man/1/unzip
You can zip them, upload, then unzip it.
!unzip file.zip
The easiest way to do this, if the folder/file is on your local drive:
Compress the folder into a ZIP file.
Upload the zipped file into colab using the upload button in the File section. Yes, there is a File section, see the left side of the colab screen.
Use this line of code to extract the file. Note: The file path is from colab's File section.
from zipfile import ZipFile
file_name = file_path
with ZipFile(file_name, 'r') as zip:
zip.extractall()
print('Done')
Click Refresh in the colab File section.
Access the files in your folder through the file paths
Downside: The files will be deleted after the runtime is over.
You can use some part of these steps if your file is on a Google Drive, just upload the zipped file to colab from Google Drive.
you can create a git repository and push the files and folders to it,
and then can clone the repository in colaboratory with the command
!git clone https://github.com/{username}/{projectname}.git
i feel this method is faster.
but if the file size is more than 100 mb you will have to zip the file or will have to add extentions to push it to github.
for more information refer the link below.
https://help.github.com/en/github/managing-large-files/configuring-git-large-file-storage
The best way to approach this problem is simple yet tricky sometimes.
You first need to compress the folder into a zipped file and upload the same into your google drive.
While doing so, Make sure that the folder is in the root directory of the drive and not in any other subfolder!. If the compressed folder/data is in other subfolder, you can easily move the same into the root directory.
Compresses folder/data in another subfolder often messes with the unzipping process when you will be specifying the file location.
Once you did the afore mentioned tasks, enter the following commands in the colab to mount your drive:
from google.colab import drive
drive.mount('/content/gdrive')
This will ask for an access token that can be generated by clicking on the url displayed in the output of the same cell
!ls gdrive/MyDrive
Check the contents of the drive by executing the above command and ensure that your folder/data is displayed in the output.
!unzip gdrive/MyDrive/<File_name_without_space>.zip
eg:
!unzip gdrive/MyDrive/data_folder.zip
Executing the same will start unzipping your folder into the memory.
Congrats! You have successfully uploaded your folder/data into the colab.
zip your files zip -r file.zip your_folder and then:
from google.colab import files
from zipfile import ZipFile
with ZipFile(files.upload(), 'r') as zip:
zip.extractall()
print('Done')
So here's what you can do:
-upload the dataset desired folder to your drive
-over colab, mount the drive wherein this
"from google.colab import drive
drive.mount('/content/gdrive')"
automatically shows up and you just need to run it
-then check for your file over the Files section on the left-hand side (if folder not visible try refreshing, also there should be a drop-down arrow next to it where you can check all the files under the folder )
-left-click over the folder wherein you get a COPY PATH option
-paste the copied path over the desired location in your colab
How to access TFS build agent folder path in using batchfile?
I am calling runscript tool from build workflow (calling windows batchfile).
I tried to use the environment variable BUILD_REPOSITORY_LOCALPATH ($(BUILD_REPOSITORY_LOCALPATH), $env:BUILD_REPOSITORY_LOCALPATH) but they dint give any result.
Need some assistance on this.
I used another workaround for this instead of getting by workspace. From sourceDirectory folder i drill down to find my solution project file, the path containing my solution project is the local directory path i need
From batchfile i call my exe and pass %TF_BUILD_SOURCESDIRECTORY% as parameter.
string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory)
// targetdirectory would be the input parameter from batch file`
for (int i = 0; i < subdirectoryEntries.Length ; i++)
{
// My root folder always contains a specific folder with name MyFolder
// and a file Myfile.sln
if (subdirectoryEntries[i].ToString().ToLower().Contains(#"MyFolder"))
{
Console.Writeline("My source code path is " + targetDirectory);
}
//Similarly I check for Myfile.sln and then get my path.
}
This may be a very crude way, this worked for me.
The variable you are looking for is TF_BUILD_SOURCESDIRECTORY. Please refer to the XAML build documentation.
TF_BUILD_SOURCESDIRECTORY: The sources sub-directory of the build agent working directory. This directory contains your source code. For example: C:\Build\BuildBot3\CoolApp\CIBuild\src.
If you want to get C:\TFS_Build\src\V9, it's just local path: the path that you have mapped the server path to on your machine. There is not any built-in TF_BUILD environment variables could achieve your requirement.
You could use TFS API to get the related info, first get the workspace information for the build server's workspace, then do the get option, a sample code for your reference:
// Get the workspace information for the build server's workspace
var workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(sourcesDirectory);
// Get the TFS Team Project Collection information from the workspace cache
// information then load the TFS workspace itself.
var server = new TfsTeamProjectCollection(workspaceInfo.serverUri);
var workspace = workspaceInfo.GetWorkspace(server);
Once you have a workspace, you can query it for the path mappings. It
will do the necessary translation from server to local path based on
your workspace mappings. For example:
workspace.GetServerItemForLocalItem("C:\TFS_Build\src\V9");
and
workspace.GetLocalItemForServerItem("$/DEV/V9");
This mechanism will only work, however, if your build definition
actually sets up the workspace to include these files.
More details please refer this similar question: How do I resolve the root and relative paths of TFS folders on the server?
update from OP:
From sourceDirectory folder i drill down to find my solution project
file, the path containing my solution project is the local directory
path i need
How does one add a file or registry by editing a sequenced AppV 5.0 application?
Whenever we have tried to add a file directly under Root in the AppV 5.0 editor, the file was added to different location. Is there a reason for that?
The top directory of the package represents a location where some metadata files key to describing the package reside. The directory literally named "Root" represents the primary virtual application directory. You should be successful adding files to this directory, or any of the VFS directories, but not to the top directory of the package itself.
I have a foo.txt file in my /war folder. I'm trying to open it using the File class, but get an exception:
java.security.AccessControlException: access denied (java.io.FilePermission
/foo.txt read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:549)
...
From reading the docs on static/resource files, it seems like the text file should already be available. Does it need some extra setting to allow reading?:
https://developers.google.com/appengine/docs/java/config/appconfig?hl=en#Static_Files_and_Resource_Files
I'm using the local dev server on a mac.
Thanks
I suggest that if you are going to read data files in your Java code and need a place to put your data files (.txt or .csv), etc -- then do the following:
Go to WEB-INF folder
Create some folder inside of the WEB-INF folder. e.g. WEB-INF\data
Place your files in the above folder. E.g. sample.txt
In your Java IO code, you can then refer to the file via WEB-INF\data\sample.txt
When I connect to a web-site that is using Silverlight, my understanding is that the "XAP" file is downloaded to C:\Users\ "UserName" \AppData\Local\Temp folder (under windows Vista).
There are few sites that I know that are using "XAP" files but I don't see a "XAP" file in this folder. Any ideas?
I think I found the answer. It just gets downloaded to the logged-in user's temporary internet files folder.