directory

Search for a file in C++

岁酱吖の 提交于 2021-01-29 20:10:52
问题 I'm new in C++ and i need to search the drives for a specific file and display them or list them in a listbox. Here's what i have so far. Some bits and pieces i found in the forums and stuff i have added. My question is how do i put them together. Lets say i'm searching for a file called "test.txt" Thanks! // search for drives char* szSingleDrive; DWORD dwSize = MAX_PATH; char szLogicalDrives[MAX_PATH] = { 0 }; DWORD dwResult = GetLogicalDriveStrings(dwSize, szLogicalDrives); UINT

Search for a file in C++

二次信任 提交于 2021-01-29 16:12:51
问题 I'm new in C++ and i need to search the drives for a specific file and display them or list them in a listbox. Here's what i have so far. Some bits and pieces i found in the forums and stuff i have added. My question is how do i put them together. Lets say i'm searching for a file called "test.txt" Thanks! // search for drives char* szSingleDrive; DWORD dwSize = MAX_PATH; char szLogicalDrives[MAX_PATH] = { 0 }; DWORD dwResult = GetLogicalDriveStrings(dwSize, szLogicalDrives); UINT

C++ MoveFile giving ERROR_ACCESS_DENIED inconsistently for directory moves on Windows Server

醉酒当歌 提交于 2021-01-29 13:24:15
问题 I am having a problem moving a directory to a new location, specifically one I create with CreateDirectory . Here is the code: if (FALSE == CreateDirectory(strDestination, NULL)) { dwError = GetLastError(); if (ERROR_ALREADY_EXISTS != dwError) { strError.Format("Error creating %s: %i", strDestination, dwError); LogIt(strError); } } if (FALSE == MoveFile(strSource, strDestination + strID)) { dwError = GetLastError(); strError.Format("Error moving %s to %s: %i", strSource, strDestination +

VBA code to check and create folder system and save file

对着背影说爱祢 提交于 2021-01-29 13:00:16
问题 I'm looking to create a code that takes an active worksheet which once completed and a button is selected it saves it as a new workbook within a folder / subfolder system based on multiple cell values. Some of the cells may stay the same but others may change, giving a variety of potential paths which could already part exist or not exist at all. I've managed to put a code together which does just that but when I change one of the cell values, which ultimately changes the path slightly, I get

PYTHON | Copying a file from an unknown destination

不羁岁月 提交于 2021-01-29 07:19:31
问题 Hi my name is Oscar and I would like some help! So the scenario I have is that I am trying to write a python code that will copy itself and put that copy in another directory. I know that you can use the shutil command. For example: import shutil shutil.copy("C:\Users\%user%\Downloads\file.txt", "C:\Users\%user%\Documents") But I want to just copy the file so that the script works on any computer that it is located on, for example: import shutil shutil.copy("file.txt", "C:\Users\%user%

Using DirectoryInfo.Exists is false even if the directory exists

亡梦爱人 提交于 2021-01-29 06:05:32
问题 I'm having a problem when creating a DirectoryInfo, The directory I give when creating the DirectoryInfo is this: "S:\PUBLICO\ESTUDIOS DIGITALIZADOS\PREVENTIVA\ELECTROS\2020\01-ENERO\08\" And when checking if DirectoryInfo exists it's false, even though it exists. This is a problem because it throws an exception even when using di.GetFiles(). Also, when accessing folders from 2019 instead of 2020 it works perfectly, and uses the exact same code This is the code that matters: strDirectorioBase

How to list only user provided file names from the directory in C?

大城市里の小女人 提交于 2021-01-29 05:57:22
问题 I know how to printf all files from the directory,but how i find one specific file in that directory using name provided earlier by user? #include <dirent.h> #include <stdio.h> int main(void) { DIR *d; struct dirent *dir; char a,b; printf("Path:(eg.c:/): "); scanf("%s",&a); d = opendir (&a); if (d) { while ((dir = readdir(d)) != NULL) { printf("%s\n", dir->d_name); } closedir(d); } return(0); } 回答1: From comments: I would like to know how to implement this in my code because I have never used

Python: Create directory tree from nested list of dictionaries

你离开我真会死。 提交于 2021-01-29 05:29:24
问题 How can I create a directory tree from the below list of dictionaries in python? The number of subdirectory levels has to be variable. dirTree: [{'level-1_dir-1': ''}, {'level-1_dir-2': [{'level-2_dir-1': [{'level-3_dir-1': ''}, {'level-3_dir-2': ''}, {'level-3_dir-3': ''} ] }, {'level-2_dir-2': ''} ] }, {'level-1_dir-3': ''}, {'level-1_dir-4': ''} ] I would like to accomplish something like the following tasks with python: Iterate through the level-1 keys create folder with key name if it

save files into a specific subfolder in a loop in R

只谈情不闲聊 提交于 2021-01-29 03:07:06
问题 I feel I am very close to the solution but at the moment i cant figure out how to get there. I´ve got the following problem. In my folder "Test" I´ve got stacked datafiles with the names M1_1; M1_2 , M1_3 and so on: /Test/M1_1.dat for example. No I want to seperate the files, so that I get: M1_1[1].dat, M1_1[2].dat, M1_1[3].dat and so on. These files I´d like to save in specific subfolders: Test/M1/M1_1[1]; Test/M1/M1_1[2] and so on, and Test/M2/M1_2[1], Test/M2/M1_2[2] and so on. Now I

save files into a specific subfolder in a loop in R

和自甴很熟 提交于 2021-01-29 03:05:52
问题 I feel I am very close to the solution but at the moment i cant figure out how to get there. I´ve got the following problem. In my folder "Test" I´ve got stacked datafiles with the names M1_1; M1_2 , M1_3 and so on: /Test/M1_1.dat for example. No I want to seperate the files, so that I get: M1_1[1].dat, M1_1[2].dat, M1_1[3].dat and so on. These files I´d like to save in specific subfolders: Test/M1/M1_1[1]; Test/M1/M1_1[2] and so on, and Test/M2/M1_2[1], Test/M2/M1_2[2] and so on. Now I