It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a directory path like this \servername\DirectoryName\.csv and in that there are multiple csv files of similar name pattern now I want to copy that from one directory to another in c#.Can anyone help me out with this.
var sourceDir = #"c:\sourcedir";
var destDir = #"c:\targetdir";
var pattern = "*.csv";
foreach (var file in new DirectoryInfo(sourceDir).GetFiles(pattern))
{
file.CopyTo(Path.Combine(destDir, file.Name));
}
Use Files.Copy() method. See msdn here.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want to know what would be the equivalent C# code for the perl system() function, see below code
$flac = `/usr/bin/which flac`;
($fh, $tmpname) = tempfile("stt_XXXXXX", DIR => "/tmp", UNLINK => 1);
/// Some code for recording
$endian = (unpack("h*", pack("s", 1)) =~ /01/) ? "big" : "little";
$samplerate = 8000;
$format = sln;
if(system($flac, $comp_level, "--totally-silent", "--channels=1", "--endian=$endian", "--sign=signed", "--bps=16", "--force-raw-format", "--sample-rate=$samplerate", "$tmpname.$format") != 0)
{
if (open($fh, "<", "$tmpname.flac"))
{
$audio = do { local $/; <$fh> };
close($fh);
}
}
Please help me solve my problem, digging on internet won't help me. Thanks
The system call in perl most likely calls the command line processor of the operating system with the given string.
In C#, you would use System.Diagnostics.Process.Start to start a new process. The MSDN has examples to start from.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
How to check is a List entry is not e.g. 0.0?
I just know how to check if it is 0.0 like this:
MyList.Where(a => a.Equals(0.0))
but how to check it if it's not?
To check if a list contains a number: if (myList.Contains(0.0)) ...
To check if a list does NOT contain a number: if (!myList.Contains(0.0)) ...
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I try just an old VB application in c# to convert, while I've encountered this line of code:
Mid(strData, intPosition + 1, intLenght) = strValue
How can it be translated into c#?
You would have to combine Remove and Insert, something like:
strData.Remove(intPosition, intLenght).Insert(intPosition, strValue);
The above assumes that the length of strValue was equal to intLenght. If strValue might be longer, then to replicate the Mid statement, we would need to do:
strData.Remove(intPosition, intLenght)
.Insert(intPosition, strValue.Substring(0, intLenght));
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
htmlCode = client.DownloadString("http: //abc.com");
When executed, the html has unicode characters such as 来这. How can I convert it correctly and then display in a textbox?
Try using:
WebClient client = new WebClient();
TextBox1.Text = HttpUtility.HtmlDecode(client.DownloadString("http://abc.com"));
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
string last = url.Substring(url.LastIndexOf('/') + 1);
var provisionedSiteRequestRep = provisioningRequestRepository.SelectFirst(new WhereSpecification<ProvisioningRequest>(result => result.SiteUrl.Contains(last.ToString())));
Some time i am getting the null values of last.tosting() so i am getting exception for this code how to resolve this?
You are facing problem on this line
(result => result.SiteUrl.Contains(last.ToString());
Can you please check that SiteUrl is type of string otherwise it not going to work for you.
because last is type of string and Contains is method supported by string type ...
or
otherwise last need to be enumebrable collection and siteurl also enumerable collection than and only than Contains is supported