|
I work for a company that has a software product that operates with a standardized programdata directory/file structure. In that selection of directories and files there are many xml files that has a bunch of information that we dig through when researching to find root cause or trouble-shooting with customers, etc. By the way, I'm a qa test engineer. I want to build a tool (preferably in c# because i'm working on learning it) that has a way to point out the location of an exported or stored \programdata\our_application\data and it does it's thing. This tool would go through the directories and files and pull out specific information/data from the xmls like, what locale the user was in, what mode was the user working in, what worksite, whether or not debugging is turned on, etc. Then it would display this information on a GUI that I'd like to design with possibly checkboxes to turn some of it off if it isn't wanted or some sort of control over what information it delivers. Our Dev and QA teams would keep this handy and when they started to research an issue they'd run it and it would display all the information that we currently have to dig around in directories and xml files for. It would be nice if I could make it where the data items/nodes displayed could be changed in the same GUI when the "send"? button was pushed which would then make changes in the app when run again.
Any suggestions? Location of a sample that I can use to copy? Am I totally using the wrong language? Anything helps!
Thank you in advance for your help.
|
|
|
|
|
This seems a perfectly reasonable tool to use C# for. If I were you, I would write this with Windows Forms because you aren't going to want the added complexity of learning WPF on top of this. In order to query for the files, you would be looking at using something like this to retrieve the XML files (assuming you are looking in a flat directory structure):
DirectoryInfo di = new DirectoryInfo(pathToFolder);
FileInfo[] files = di.GetFiles("*.xml"); In this example, I'm retrieving the FileInfo because we can use this to determine things like when the file was last accessed - this is a handy way to remove files you have already looked at. In order to parse the files, you should probably look into using XLinq (that's XML for LINQ) - if you Google on this, you'll find lots of examples on how to use this.
Good luck with your development, and don't forget to come back if you have particular problems you are stuck with.
|
|
|
|
|
A better syntax for "private protected"?
C# vNext will have a new accessibility modifier. The C# team had first proposed to use "private protected", but maybe someone can find a better syntax for it.
On this survey[^] every syntax that's been proposed so far has been gathered together for everyone to vote on her/his favorite.
WHAT IS THE NEW ACCESSIBILITY MODIFIER ABOUT? ... This post[^] on StackOverflow has a great explanation.
WHERE CAN YOU JOIN THE DISCUSSION? ... Read the motives behind all these proposals - and help shape the future of your favorite programming language - on the CodePlex discussion forum
Go ahead and choose your favorite. The C# team will gathering up answers in mid May.
C# vNext language design - private protected - FamilyAndAssembly[^]
|
|
|
|
|
You forgot the link to CodePlex:
https://roslyn.codeplex.com/discussions/541194[^]
This might be better in the Lounge or Insider News, as it's not really a question.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Since the link was already on the survey...
Good point but this is C# related and that's why I didn't mark it as a question.
|
|
|
|
|
Hi all,
y = 2;
string yString = y;
This of course does not work ,Cannot implicitly convert type 'int' to 'string'.
But this is no problem:
y = 2;
string yString = "" + y;
Why??
Regards,
Grooover
0200 A9 23
0202 8D 01 80
0205 00
|
|
|
|
|
Because the designers of .NET C# decided that the "+" operator between strings ... if the item before the plus-sign is a string ... would automatically invoke conversion of all items to the right of the plus-sign to Type String.
You can see an even more dramatic example of this if you execute:
int v = 1;
Int32 w = 2;
Int64 x = 3;
double y = 4;
float z1 = 5;
Single z2 = 6;
string yString = "" + v + w + x + y + z1 + z2; Yep, it compiles. So, you can infer that ... given a lack of parentheses) arithmetical operator evaluation for the plus sign is "turned off."
If you think this is kind of strange, you may not be alone
“I speak in a poem of the ancient food of heroes: humiliation, unhappiness, discord. Those things are given to us to transform, so that we may make from the miserable circumstances of our lives things that are eternal, or aspire to be so.” Jorge Luis Borges
|
|
|
|
|
Thank You for your explanation,
Learn something every day.
thanks
0200 A9 23
0202 8D 01 80
0205 00
|
|
|
|
|
Thing of beauty, .NET.
Regards,
Rob Philpott.
|
|
|
|
|
The concatenation operators are replaced by calls to one of the overloaded string.Concat methods. There are versions with string or object parameters, e.g Concat(string, string, string), Concat(object, object, object), and if possible the more efficient (string, string, ...) versions will be used.
This gives us, well me really, the opportunity to play with ILDASM and have a look at what the C# compiler decides to do.
private static String StringConcat(String a, String b, String c) {
return a + b + c;
}
private static String ObjectConcat(String a, int b, DateTime c) {
return a + b + c;
}
and the IL shows the use of the different Concat methods.
.method private hidebysig static string StringConcat(string a,
string b,
string c) cil managed
{
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: ldarg.2
IL_0003: call string [mscorlib]System.String::Concat(string,
string,
string)
IL_0008: ret
}
.method private hidebysig static string ObjectConcat(string a,
int32 b,
valuetype [mscorlib]System.DateTime c) cil managed
{
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: box [mscorlib]System.Int32
IL_0007: ldarg.2
IL_0008: box [mscorlib]System.DateTime
IL_000d: call string [mscorlib]System.String::Concat(object,
object,
object)
IL_0012: ret
}
Alan.
|
|
|
|
|
Hi all.
I need to write to a file --file names-- while looping a folder. So i did this:
string foldername = this.srcfbdlg.SelectedPath;
StreamWriter sw = new StreamWriter("data.txt", true);
var txtFiles = Directory.EnumerateFiles(foldername, "setup.exe", SearchOption.AllDirectories);
foreach (string currentFile in txtFiles)
{
string fileName = currentFile.Substring(foldername.Length + 1);
File.AppendAllText("data.txt", fileName);
}
The problem is, while looping, AppendAllText() gives me the error "File cannot be accessed. I think that's because while looping the writing process overlaps, hence the bug. Is there a way around, without like making a timer to write or something?
Thanks for any reply guys.
|
|
|
|
|
OK...you can't see the problem yourself?
You have two different methods of adding data ready and in use in that code:
StreamWriter sw = new StreamWriter("data.txt", true); Sets up sw to append to the file data.txt - which means opening the file and acquiring an exclusive lock so the file content can;t be changed while you are writing to it.
Then:
File.AppendAllText("data.txt", fileName); Which tries to open the file data.txt for append by acquiring an exclusive lock so the file content can;t be changed while you are writing to it.
And fails, because there already is an exclusive lock open on the file...by your code.
So, either use the sw stream to write to the file, or get rid of it completely, and just use the File.AppendAllText method instead - but don't try to use both.
And if you do go with your own stream (which in this case is probably a good idea as you only open and lock the file once) remember to Close and Dispose the stream when you have finished - or the next time you call that code the file will still be locked from the first time!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Hey thanks man learned some stuff from that. And it worked :v
Later
|
|
|
|
|
You're welcome!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Hi..!
i want to make an application in C #
that will standardized .ppt and .pptx files.
now i want to extract the text in files
and check following properties.
font style, font size,heading and sub heading style and size, number of bullets in each slide etc..
Can anyone help to do the following things in C Sharp..
please share your ideas and experience related to this with me.
All of you are warmly welcome..
Thankssss in advance....
|
|
|
|
|
|
thanks but how can i change the font size and style in a ppt file through C#.
|
|
|
|
|
taimurhasan wrote: how can i change the font size and style in a ppt file through C#. You will have to find the appropriate calls in the interop as documented in the link I gave you.
|
|
|
|
|
|
If you know how to do it within Powerpoint, record your actions as a macro, then look at the generated code - this will give you big hints about what you need to do in C#, even though the code will be in VBA
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Sorry i can't understand what you want to say.. can u explain ??
|
|
|
|
|
Hi I'm brand new to this stuff and still grasping the concepts and terms associated with C#
I was looking through my C# book and came across this example project. It asked you to create a one-form application that will gather the following:
First Name
Last Name
Address
City
State
Zip
Telephone
You must include the following features:
The form must start in the center of the screen.
You must have a nice title for your form.
There must be an END button that stops your program.
You need another button that will display a message box when they click it. The message needs to say "Thanks for shopping [Name]".
All the fonts/colors/alignments must look clean and orderly.
I know to an experienced C# programmer, this kind of stuff is second nature. I'm looking for anyone who could help me out with any infomation so I can understand this a little more (since the book didn't show how to do it!) Thanks!
|
|
|
|
|
|
Member 10784174 wrote: the book didn't show how to do it!
Your book probably does show how to do it, but it won't spell it out for you - part of learning development is learning to think about the problem and work out a solution - it expects you to apply what it has told you, not blindly regurgitate it (unlike most school work).
If you can't work out what it means in one go, then do each bit separately: first, center the form. Then change the title. And so forth. Doing it that way, it's a very simple task, honest!
If you don't think the book has explained what you need to do, then there are two possibilities:
1) It's a rubbish book. Check the title: does it have "for Dummies", multiple exclamation marks, or "in xxx days" in it? If it does, then it's almost certainly rubbish. If it doesn't, it's probably ok.
2) You aren't reading the book, just skipping through and trying one of the exercises without trying to understand the material in the chapter(s) before it.
The solution to the first is simple: get a better book. Anything by Addison-Wesley, or Wrox is probably fine.
But I suspect you need the second solution: Go back to page one, and start reading from there. And do the exercises in order as you meet them!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Interesting book that only asks you to do stuff without explaining it first. What is the title?
Regards,
Rob Philpott.
|
|
|
|
|