extract and format string in text file? [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
i have a text file in a format
CODE:8000012016
502 Bad Gateway
502 Bad GatewayHost Not Found or connection failed
CODE:8000012146
502 Bad Gateway
502 Bad GatewayHost Not Found or connection failed
CODE:8000023700
502 Bad Gateway
502 Bad GatewayHost Not Found or connection failed
.
.
.
.
.
.
.
.
CODE:8001129584
{"event_id":"0D004B66AA326A34","version":"1.6","error":{"system_unavailable":true,"no_tickets":true,"invalid":{"ticketing":true}},"command":"event_authenticate"}
CODE:8001129586
{"event_id":"0D004B66AA326A34","version":"1.6","error":{"system_unavailable":true,"no_tickets":true,"invalid":{"ticketing":true}},"command":"event_authenticate"}
.
.
.
.
.
i have to seperate these two formats and save in new different text files.

OK, more details please... As I see, you can search for HTML tags.
for example:
foreach(LineOfText line in text)
{
foreach(Word in line)
{
if(Word is HtmlTag)
{
mark current line as type1;
put current line in string1;
}
else
{
mark current line as type2;
put current line in string2;
}
}
}
SaveString(string1);
SaveString(string2);

Related

The target path "" is a directory and not a file [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I am trying to copy a file into another folder, here is my code.
private static void CopyDirectory(DirectoryInfo source, DirectoryInfo target)
{
foreach (var sourceFilePath in Directory.GetFiles(source.FullName))
{
FileInfo file;
if(IsAccesable(sourceFilePath, out file))
{
file.CopyTo(target.FullName); //ERROR HERE
}
else
{
//DO WORKAROUND
}
}
foreach(var sourceSubDirectoryPath in Directory.GetDirectories(source.FullName))
{
DirectoryInfo directory;
if(IsAccesable(sourceSubDirectoryPath, out directory))
{
var targetSubDictionary = target.CreateSubdirectory(Path.Combine(target.FullName, sourceSubDirectoryPath));
CopyDirectory(directory, targetSubDictionary);
}
else
{
//DO WORKAROUND
}
}
}
I keep getting the error message: The target path "" is a directory and not a file
Full sourcePath:
"c:\\Hypixel Bots Interface\\.gitattributes"
Full targetPath:
"C:\\Users\\wout\\source\\repos\\FileCloner\\FileCloner\\bin\\Debug\\net5.0\\Target\\Hypixel Bots Interface"
There is no file in your path. For example, create a file in your folder and name it test.txt an run again your code to verify if the error will disappear.
"C:\Users\wout\source\repos\FileCloner\FileCloner\bin\Debug\net5.0\Target\Hypixel Bots Interface\.gitattributes\test.txt"
As the error says, you want the targetPath to be a file name. You are just pointing to a folder.
"C:\\Users\\wout\\source\\repos\\FileCloner\\FileCloner\\bin\\Debug\\net5.0\\Target\\Hypixel Bots Interface\\.gitattributes"
That would be pointing to a new file in that directory

Selenium C# Interact with Chrome Microphone Window [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have an application that when initiated, I receive the popup that "https://example.com wants to:"
"Use your microphone"
I have looked at autoit but it has not been helping. I was trying to use an x/y coordinate but no luck. The autoit window info gives me a name and a class but button info is not there.
Anyone have a way around this issue?
Works perfectly:
$WinTitle = "[CLASS:Chrome_WidgetWin_1]"
WinWait($WinTitle)
WinActivate($WinTitle)
ControlSend($WinTitle, "", "", "{TAB}{ENTER}")
Here is how I got around it using AutoIT. Remove one of the Send("+{TAB}") to set it to Block. I tried removing both of these and just using the enter for Allow but it did not work.
Allow Microphone for Chrome:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=chromeClickAllow.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Sleep(2000)
WinActivate("Tabs Outliner")
WinWait("[CLASS:Chrome_WidgetWin_1]")
Sleep(500)
WinActivate("[CLASS:Chrome_WidgetWin_1]")
Send("+{TAB}")
Send("+{TAB}")
Send("{ENTER}")

System.ServiceModel.FaultException in WCF service [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a WCF service which worked fine til today, an exception System.ServiceModel.FaultException was thrown, when i call a method of the this service.
using (EService = new FaService.EServiceClient())
{
DataSet ds = EService.GetCompanies(3375); // exception here
DataTable dt = ds.Tables[0];
foreach (DataRow dr in dt.Rows)
{
Companies.Add(new Company() { Name = dr["c0"].ToString() });
}
}
In a service, the FaultException class is used to create an untyped fault to return to the client for debugging purposes. It really handles generic or "unknown" faults in a process in the program/client. You can pinpoint the error down to a line and typically can just debug your system/program/client to find where this "unknown" error is occurring. It may be helpful to post this method's code in which you are having issues, but as for your post thus far, I would debug your program and step line by line to make sure there isn't any unnecessary lines of code.
Reference: http://msdn.microsoft.com/en-us/library/system.servicemodel.faultexception(v=vs.110).aspx

How can I load kongregate chat in my webbrowser? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have a simple program, and I am trying to load the kongregate chat into a WebBrowser, but it is not working...
When I first start it up, it navigates to a game, and then it gives me 4 Script Error, and the chat just sits there saying: "Joining room...". I don't think it is a problem with the browser settings, because it works on internet explorer. Is there something that is messed up with my WebBrowser? I have let it sit there for a few minutes, and it still does not work. I have set the suppressScriptErrors to true and false, and it still does not fix it.
FYI: I am not doing anything bad with my program, like cheating, or spamming, or anything like that, I just want the webpage to show up, and sometimes I like to be able to have things copied, so I put a few TextBoxes to the right of it, so I can paste it into chat, if I won't to post a few things...
This article has the solution to your problem. It appears that the WebBrowser control in Visual Studio launches in IE7 mode by default. That's why you get javescript errors with the control but, not in your browser. I highly suggest you read the article linked that the top. Luckily, there is a fix. The following code was taken from another stackoverflow answer to a question that indirectly addresses your issue. Here is that link, and here is the code.
string installkey = #"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
string entryLabel = Path.GetFileName(Application.ExecutablePath);
System.OperatingSystem osInfo = System.Environment.OSVersion;
string version = osInfo.Version.Major.ToString() + '.' + osInfo.Version.Minor.ToString();
uint editFlag = (uint)((version == "6.2") ? 0x2710 : 0x2328); // 6.2 = Windows 8 and therefore IE10
RegistryKey existingSubKey = Registry.LocalMachine.OpenSubKey(installkey, false); // readonly key
if (existingSubKey == null) {
existingSubKey = Registry.LocalMachine.CreateSubKey(installkey, RegistryKeyPermissionCheck.Default); // readonly key
}
if (existingSubKey.GetValue(entryLabel) == null) {
existingSubKey = Registry.LocalMachine.OpenSubKey(installkey, true); // writable key
existingSubKey.SetValue(entryLabel, unchecked((int)editFlag), RegistryValueKind.DWord);
}
Also, the article I mentioned up top says that you should create an entry for the VS host process for your app too or it won't work in debug mode. Good luck and I hope this solves your issue!

How can i run bat file i just added to the resources in my project properties? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I went to my project > properties > resources > add existing file > test.bat
Now i have this code :
private void Information()
{
}
I call this function from a button click event.
I want to execute the bat file, so every user which will use my program will be able to execute the bat file directly from the program.
The bat file just create dxdiag.txt in a specific directory.
How can i do that?
You can put the batch file into the executable file folder and then use the Process class like this:
System.Diagnostics.Process.Start(System.IO.Path.Combine(Application.StartupPath, yourBatFileName));
Pay attention that usually your solution is compiled into the Debug folder or into the Release folder depending on your configuration (so you have to put the file in the correct one).
Use this class
Process.Start Method
You can use the following for parameters...
var myProg = new System.Diagnostics.Process();
myProg .StartInfo.FileName = "file name with full path";
myProg .StartInfo.UseShellExecute = false;
myProg .StartInfo.Arguments = "";
myProg .StartInfo.RedirectStandardOutput = true;
myProg .StartInfo.CreateNoWindow = true;
myProg .Start();
myProg .StandardOutput.ReadToEnd().Dump();

Categories

Resources