0
C# code help
I written a code which is compare 2 text files and writing that result in to another file Now i want to all the files in 2 different folders How to do it ??
4 Answers
+ 1
You want to move the file in different folders through code or you just want to open the file in a different folder? Either way you can simply when create/open a file you just give the path to the folder you want it to be stored, for example:
string filepath = “c:\\somefolder\\anotherfolder\\file.txt”;
string text = “some text”;
File.WriteAllText(filepath, text);
0
Help me
0
No i want compare the files in both the folders
Like i have source and target
In each folder there are some directories and having multiple files
But in the 2 folders file names are same
I want to compare those files
0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace PostDeploymentVerificationTool
{
class FileComparision
{
public static void Main()
{
//string fileA, destinationPath, fileC;
//fileA = "D:\\Source\\f1_Source.txt";
////destinationPath = "C:\\Target\\f1_Source.txt";
string fileC = "D:\\sourceresult.txt";
string sourcePath = @"C:\SourceFolder";
string destinationPath = @"C:\targetFolder";
string fileName = Path.GetFileName(sourcePath);
string filename1 = Path.GetFileName(destinationPath);
string source = Path.Combine(sourcePath, fileName);
string destination = Path.Combine(destinationPath, filename1);
DirectoryInfo dir1 = new DirectoryInfo(sourcePath);
DirectoryInfo dir2 = new DirectoryInfo(destinationPath);