|
How do i change user properties.
public string SetAttributesValue()
{
try
{
RunspaceConfiguration rsConfig = RunspaceConfiguration.Create();
PSSnapInException snapInException = null;
PSSnapInInfo info = rsConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out snapInException);
Runspace myRunSpace = RunspaceFactory.CreateRunspace(rsConfig);
myRunSpace.Open();
Pipeline pipeLine = myRunSpace.CreatePipeline();
Command myCommand = new Command("Get-user");
myCommand.Parameters.Add("Identity", sUserName);
pipeLine.Commands.Add(myCommand);
Collection<psobject> commandResults = pipeLine.Invoke();
foreach (PSObject cmdlet in commandResults)
{
}
return commandResults.ToString();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
return null;
}
|
|
|
|
|
hey, i m working on a project , i am developing it in visual studio 2010, c# winforms and devexpress (also trying to change it to WPF MVVM)
its a kind of toolbox, toolbox should be generic i.e. if any new tool added, toolbox should automatically add it (when in network), toolbox and tool both should be auto update (i am using clickonce for this), i am using process.start to run a tool from toolbox (bcz toolbox and tools are loosely coupled), but now the new requirement is, that dlls which are using by different tools should reside with toolbox only and tool should have their reference only (i find it very difficult bcz toolbox is loosely coupled with tool) so if you can suggest anything that can help me to keep all dll with one application (toolbox) and other are only using ref. of it (tools)..or in another solution, if we have tight coupling between toolbox and tools (one solution , multiple project) then how can we achieve this function (dll only at one place) also the autoupdate (because clickonce is not supporting multiple project deployment as far as i know)..any help on this is appreciated.
JP
SSE
|
|
|
|
|
Read up on interfaces; create one in a new dll, and reference that from the toolbox and the tools.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
thanks you. i am working on the solution you suggest. will post my reply as soon as i get it working.
|
|
|
|
|
Good luck. I'd recommend doing a small testproject in a new and clean solution. That way you can focus on this particular task without being bugged by any other code.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
What about MEF[^]?
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|
Hi Amit, thanks for suggestion..i dont know much about MEF, But surely look into this direction as well..
|
|
|
|
|
Hi everyone,
I am creating XML spreadsheet in C# and save it as Excel file (.xls). After creating, I have a excel with the size is: 500KB
But, after opening it and click "save" button without changes, the new size is: 2.5MB
Are there anyone know why and how to fix it ?
Please see my excel file at the link: http://www.mediafire.com/?5irdbchc10nonq4[^]
Thanks and regards,
Tai
|
|
|
|
|
What makes you think this is a problem, you are expecting an xls file to be the same size as a text file!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi RAH,
The changing the size of file after saving the excel file is problem. It make the file slower when opening.
Thanks and regards,
|
|
|
|
|
taibc wrote: It make the file slower when opening
Amazing, imagine that. sorry sarcasm got the better of me.
To test the excel size why don't you copy/paste the data from your sheet to a new sheet, save it and compare the sizes. Only if the new file is not 2.5 mb do you have a problem.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Rah,
I did as your suggestion The new file is 200KB. I haven't known why ? Could you please open and check that file ?
Thanks and regards,
|
|
|
|
|
taibc wrote: Could you please open and check that file
Sorry I am not an excel expert, I suggest you chase this down through the MSDN forums as I would think it is an Excel problem not a c# issue.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes, thank you.
Maybe there is something wrong with my xml string format
|
|
|
|
|
taibc wrote: I have a excel with the size is: 500KB
But, after opening it and click "save" button without changes, the new size is: 2.5MB
It's by design. XML is exactly that; XML, not a XLS file. If you open it in Excell, it'll parse it correctly. But save it in Excell, and it'll generate an Excell-file (.xls), and not write in your XML-format.
You might want to use a CSV file instead.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi Eddy,
Thank you.
So, I can save xml string as "CSV" file ? But, I am wanting to creat .xls file from xml string.
Do you have any ideas ?
|
|
|
|
|
taibc wrote: But, I am wanting to creat .xls file from xml string.
XML is not a native Excell-format. Creating an .xls file is not the same as dumping your data as Xml and renaming the extension - it will still be XML (even if Excell can read it without problems) and as soon as you save it, it will become a "real" XLS-file. That will contain more than Xml, as it will contain even properties that identify the author.
taibc wrote: So, I can save xml string as "CSV" file ? <layer>But, I am wanting to creat .xls file from xml string.
CSV would behave in a similar way, but at least it'd be very clear that it's no longer an Excell-file
If you want a "real" Excell file (the large ones), you'll need to create a file using Excel-interop and move the Xml values into a worksheet.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you ,
How can I move Xml values (xml string) into a worksheet ?
|
|
|
|
|
As Richard notes, if you want to write a file in the native Excell-format, you'll have to InterOp to Excell. One problem to be expected is that the interop-libraries are tied to a specific version of Office. Use Office-2007 interop, and you'll be able to write .xls and .xlsx files. Do note that the native format is also tied to a specific Office-version. Second point is that one would need a license for Excell.
Alternatively, you could try searching for some third-party libraries. Most people will spit out an XML or CSV and not bother with it, unless there's a need to have some formatting in there.
Why is it such a big problem if the file grows a bit?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks Eddy,
I had a solution for this. I used Interop.Excel to open the file and Save as a normal workbook, and the result is ok (the size is smaller, and don't have any problems).
Thanks and regards,
|
|
|
|
|
The default "SaveAs" option in this spreadsheet is to save as XML Spreadsheet, which is text, and therefore takes much more space on disk. Save it as Excel Workbook and it is the same size.
Use the best guess
|
|
|
|
|
Hi Richard,
I used "Save" button (not SaveAs), but the size is bigger after saving
|
|
|
|
|
Yes, and it is because the default format for saving this file is XML Spreadsheet, as I mentioned above. If you open that file with a text editor you will see that it is an XML file. You need to use SaveAs to change the default to Excel Workbook.
Use the best guess
|
|
|
|
|
Oh, you are right.
How can I save this file to Excel Workbook using C# ? So, users only need to open and save it (not save as)
I used below codes to save xml string as .xls file.
<pre lang="c#">
FileStream fs = File.Open(path, FileMode.Create, FileAccess.Write);
StreamWriter stmWriter = new StreamWriter(fs, System.Text.Encoding.UTF8);
stmWriter.Write(strXMLContent);
Thanks and regards,
Tai
|
|
|
|
|