C Sharp :: Copying A File From Current Directory To System Drive
Feb 8, 2014I have tried to use File.Copy and File.Move but non of them would work as I expected .....
View 1 RepliesI have tried to use File.Copy and File.Move but non of them would work as I expected .....
View 1 RepliesI have an extremely annoying problem, I am inserting data into an access database and now i have noticed that it is copying itself to the bin/debug folder on ts own and yet i have set "Copy to Output Directory" property to "Copy never"
But without fail, it is copied! It is making any attempted updates to the database's information invalid since its not updating at all.
This all started when i installed crystal reports and it asked me to make a duplicate of the database in order to utilize data-sets that were created for certain reports.
Why this is happening? I cannot test my application properly at all.
I'm trying to output only a few files, using regex, from the current directory, this is my main code:
Code:
// main.cpp
{
char * _dir = new char[MAX_PATH];
getcwd(_dir, MAX_PATH);
unique_ptr<CExtractor> _ptr(new CExtractor(_dir));
delete[] _dir;
}
Code:
// CExtractor.cpp
DIR *pdir = NULL;
struct dirent *pent = NULL;
pdir = opendir(_cwd.c_str());
while ((pent = readdir(pdir)) && (pent->d_type != DT_DIR)) {
if (regex_match(pent->d_name, regex(".(in|txt)$"), std::regex_constants::icase)) {
cout << pent->d_name << endl;
}
}
closedir(pdir);
My code is compiled correctly, but when I run my binary, nothings is outputed..here are my files in the current directpory:
aclocal.m4 config.guess config.status depcomp m4 NEWS
AUTHORS config.h config.sub INSTALL Makefile README
autom4te.cache config.h.in configure install-sh Makefile.am src
ChangeLog config.h.in~ configure.ac libtool Makefile.in stamp-h1
compile config.log COPYING ltmain.sh missing
I have a few "in" files
I am currently working on a program that will take an image and compare it with all other images in the current directory and sub-directories. I decided to use Qt for this as Qt has a QImage class with an overloaded == operator. This seems to work well if there are duplicates of the same size.
However, my goal is to not only find duplicate images of the same size, but the same image which may be a different size. To do this, I shrink the larger image to the size of the smaller image using the QImage scaled function.
The concern I have with this is that the scaling isn't done the same way the smaller image may have been scaled. I tested this by shrinking a copy of a picture in Paint, that image does not get deleted. I believe that == is looking for an identical image, so when I do the shrinking (via that scaled function), even if it is of the same picture I shrunk in Paint, the two methods of shrinking are not identical, and so the images appear different.
Any better method I can try? Something that can allow for slight deviations, such as an image being 99% "the same" as another. (I admit here that I will need to define some metric for what "the same" means.) In this case, the method assumes they are "identical" and gets rid of one of them.
The main way I can think of doing this is to go through each image, one pixel at a time. If the two pixels from the different images at the same index are the same, then I can increment a same pixel counter. If this number is 99% (or some other threshold) of the total pixel count, I can make the assumption the images are the same.
I've forgotten how to include a path to a folder from my current directory!
I mean, instead of loading my dice images as "dice6.png", I'm trying to load them from a file, as ".Imagesdice6.png"
Not sure why, but this isn't working. Google searching has got me nowhere.
regex pattern that takes only directory without file name
private void txtDownloadRoot_Validating(object sender, CancelEventArgs e)
{
Regex driveCheck = new Regex(@"([a-zA-Z]:[^/:*;/:?<>|]+)|({2}[^/:*;/:?<>|]+)");
if (!driveCheck.IsMatch(txtDownloadRoot.Text))
[Code].....
I am making an application that runs on Machine1 and the purpose of the application is to copy the files from Machine1 to Machine2. It works fine but i have to share the folder of the Machine2 where i copy the files.
Is it possible without sharing.
i can't seem to get my program to save the Set.savv file and encrypt it and decrypt it when user logs back on to there virtual file on a CD and writing it to the disk its self and closing the session
View 8 Replies View RelatedWhen I am filling a Application form and save this Application form Entries in database it saved successfully but below Application form in DataGridView How to show only current Entry row; There is not show a previous Entries in DataGridView?
View 1 Replies View Relatederror is giving.
int ages = 0;
ages = int.Parse(textBox2.Text);
if(textBox2.Text == "")
{
MessageBox.Show("Age Blank ......");
}
else if (ages >= 5 || ages <= 9)
{
MessageBox.Show("age must be 5 to 9 only");
}
I retrieve a null value from a nullable sql datacolumn but when I pull it into a property it automatically gets the current datetime.
How will I go about making sure that this value returns a null and not the currentdatetime.
I am doing "Virus Tracking System" Project. I have to scan the directory selected from treeview ....
View 9 Replies View RelatedI would like the user to insert a CD into their computer and click on an button on my application that allows them to read the CD-ROM and find a specific file type, e.g. csv, and then grab the info in the csv file.
I already have my StreamReader setup grabbing a filepath.
Now I am just wondering...how do I detect the CD-ROM and how do I grab the filepath of the only CSV file on the CD-ROM?
What's behind detecting a CD-ROM and grabbing a specific file type from a CD-ROM?
I heard about DriveInfo
However, that only allows me to detect a drive but not look at it's contents.
I am trying to save the excel file in D:/newfolder. but the file saving as newfolderFilename. The newfolder is already created in D drive. File save path i am getting from textbox ....
View 14 Replies View RelatedI want to read a file from my flash drive called text.csv. However, I cannot even open the port where my flash drive is connected. This is the code that I am using, but I get error since the first part. When I run the program it says "fopen Error". I am using Ubuntu 12.04.
#include<stdio.h>
#include<string.h>
#define SIZE 1
#define NUMELEM 5
int main(void) {
FILE* fd = NULL;
[Code] ....
Currently I'm trying to do something extremely basic: delete or move a file
I have a mapped network drive (Y) where I have a file I need to move from one folder to another
First was doing the obvious:
System.IO.File.Move("Y:TempFile.txt", "Y:Temp2File.txt");
Not much to go wrong here, right? As long as I have the correct permission to write in the folders and the folders exists, this would normally go smooth. But for some reason it only copies the file. The source file still exists, but it has successfully copied the file to the destination folder. No exceptions has been thrown or anything... but the file still exists in the source directory
I then changed the code to the following:
System.IO.File.Copy("Y:TempFile.txt", "Y:Temp2File.txt");
System.IO.File.Delete("Y:TempFile.txt");
Console.WriteLine("See mommy, no Exceptions");
As expected the file copies correctly, but the delete command is completely ignored. The file is not deleted, but the Console.WriteLine command is called
I'm running the application as the logged in user. The user has permission to delete the file. If I try from Windows Explorer, the file is correctly deleted. Unfortunately my application refuses to delete the file and even worse, it will not even throw an Exception.
Write a program that is able to save a list of items such as books, CDs, or DVDs and the items that are saved must have attributes associated with them. For example a book has a title, author, publisher, and ISBN.I would like to create a program that is able to save the database of items to a file on the hard drive and also retrieve it from the hard drive.I have this for a start of how to set up a storing program.
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
const int arraySize = 10;
int a[arraySize] = { 2, 6, 4, 10, 12, 89, 68, 45, 37 };
int i, hold;
[code]....
how I would code copying a file that cannot be opened (eg. any file that isn't ANSII format).
I know that for a .txt or something like that I could simply do
#include <iostream>
#include <fstream>
#include <string>
[Code].....
how I would copy a file's contents into a char buffer and copy it over to another file for files that can't be opened/read in notepad? (Example: a rar file or a .exe ) Not sure if that makes
I'm having some trouble with copying one I/O stream into another. I've put the first one into an array but I cannot get my second prompt to copy the .txt file the first prompt sees and outputs to the console. When I try and grab the info from the .txt file my first prompt sees I only see blank space in my .txt file.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <fstream>
using std::ifstream;
using std::ofstream;
[Code] .....
I wrote an application with wpf and c sharp. And I use ado dotnet framework to connect the database. Now the problem is I want a centralize database for the application. And I hav e installed sql server on one of the which I want to serve as server. I now want all other clients to be able to connect to the database through local area network. how will I do that?
View 2 Replies View RelatedHow does one go about copying one binary FILE variable to another in C++? Say I have the following:
FILE* tempFile; //is a binary file and assume already filled with contents
FILE* localFile;
tempFile, as the name implies, is stored in a temporary directory (AND has a randomized temp name) within Windows and I want to copy its contents to another file with a predefined name that is within a valid local directory (e.g. C:UsersuserMy Documents est.exe). What do I have to use?
How do I detect left mouse button down and up events on the 'Close' option of the system menu that appears when the mouse is clicked on the top left corner of a form?
View 1 Replies View RelatedI need to open a pdf file (I used system("file_name.pdf"), and it worked). Next is that I want to copy complete content of the file (I want to execute ctrl+a). I want to give this command through my C program, then I will get the content of the windows clipboard having all the copied content.
#include <stdlib.h>
#include <stdio.h>
int main(){
/* opening a file */
system("results.pdf");
///////////////////////////////////////////////////////
/////copy the content in file (execute ctrl+a)/////
////// ------------------------------------- ////
///////////////////////////////////////////////////////
return 0;
}
i have to write the current time to a file ?how to do it
View 2 Replies View RelatedWhen I have loaded a savefile with Serialize, is there some way of telling the name of the currently loaded savefile?
View 2 Replies View RelatedI would like to copy one bmp file to another using plain fstream (none 3-rd party library). I've managed to come up with something but I keep getting error:
Unhandled exception at 0x504A3442 (msvcr120d.dll) in ConsoleApplication1.exe: 0xC0000005: Access violation reading location 0x00380000.
when i try to write the content of the bmp files not the header, namely error occurs in this line:
Code : ofs_differential.write((char*)&picture, (bfh_warm.bfSize - bfh_warm.bfOffBits));
Also i am not sure if i am doing it in a right way, meaning that even after solving this error i will copy the bmp file successfully.
Code:
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
struct BITMAPfileHEADER {
unsigned short bfType;
[code]....