|
|
Hi!
I am having a typical problem ,I am using management classes to get the path for shared folders and files of the system.The code is working fine for console and winforms,but it is not working for web applications.I have tried giving admin rights to aspnet account,but the problem remains there.Please help
ManagementObjectSearcher searcher1=null;
searcher1=new ManagementObjectSearcher("SELECT * FROM Win32_Share");
try
{
foreach(ManagementObject share in searcher1.Get())
{
s=share["Path"].ToString();//for asp.net pages giving null obj ref exception
}
|
|
|
|
|
I dont know how to play dat files in a C# form .If anybody has any idea please let me know .Thank you.
|
|
|
|
|
|
Hi,
I am beginning visual c# programming with xaml.
I was told, creating xaml file can be done using xamlpad. I am not clear with how to integrate this file with visual c# project and create an corresponding .xaml.cs file and add it under .xaml file.
Can somebody guide me how to create a .xaml project with visual c#, like the sample projects available in winfx sdk samples.
Thanks,
|
|
|
|
|
Are you using Visual C# 2005 Express or Visual Studio? Or are you compiling everything by hand?
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|
|
When a value of CELL such as Grid was changed, a setting color wants to change temporarily, but is who or good advice not?
I'm Studying
|
|
|
|
|
Hi,
I have an application which will connect to server A. However if server A fails...it should try to connect to server B. I have no idea how to go about implementing this. Any suggestions?
|
|
|
|
|
What type of connection is this? Database? File share? Custom protocol?
Start by putting all of your communication-related code into a separate class (or at least identifying which classes you use fits this description): should specific exceptions get thrown, you simply reinstantiate or reconfigure the class with different parameters (telling it to use server B). In the case of a database connection, as an example, you would change the connection string.
This outlines the structure of a solution, but without more information I can't really help you.
|
|
|
|
|
Hi,
Tks for the reply. The connection is a database one. I had guess changing the connection string. However does connection lost or no connection exceptions come with common error strings.
I guessing using this.
try
{
str1 = db1;
conn.ConnectionString = str1'
conn.open();
}
catch(Exception msg)
{
if(msg.Message.ToString()=="No Connection")
{
try
{str1 = db2;
conn.ConnectionString = str1;
conn.Open();
}
catch(Exception msg1)
{
MessageBox.Show("Total Connection Lost");
}
}
}
Something like these?
|
|
|
|
|
Try: catch (SqlException ex). You can get far more from exceptions than that:
Put a breakpoint on your MessageBox.Show, then quick-view the exception when the code gets there. You'll get a lot of info from there, including the actual sub-type of the exception that got thrown.
|
|
|
|
|
tks for the reply...
ok i tried that...I'm guessing i could use the number property to specify the error that i need to process..Also, there's one thing that puzzle me. There is a ConnectionState.Broken...when will this state occur? i tried have a connection open..then pluck off the cable..so i thought this is suppose to be connection broken. However the state of the connection is still open. Is there anything that i can refer to as to detect a break in connection from an open connect?
|
|
|
|
|
hi..
i hav developed an application to send fax automatically..i want to put this application in to the system tray how can i do that..
thanks...
|
|
|
|
|
for that u can use notifyIcon
|
|
|
|
|
|
Hi,
Suppose I have:
class Point
{
private int x,y;
public void Point()
{
........
}
public int X
{
set{x=value;}
get{return x;}
}
public int Y
{
set{y=value;}
get{return y;}
}
public void Draw()
{
....
Console.WriteLine("*");
}
}
class MainApp
{
static void Main()
{
Point p=new Point();
p.X=10;
p.Y=10;
p.Draw();
}
}
I want that When i call p.Draw() ,will appear '*' at position (p.X,p.Y).
Please ,help me.
Thanks a lot!
|
|
|
|
|
hi there,
do u mean that it'll draw * character in console or window form mode?
if window form mode, u cannot use Console.writeln...
if console mode, u hv to jump the cursor to that position and simpy write start character to the console.
<< >>
|
|
|
|
|
Hi Friends,
How to use OLE object to retrieve data into Multilayerd Spread Sheet. I am able to retrieve data into multi-tab spread sheet. I could not able to pull the data into multi-layered spread sheet.How to create Multi-Layered spread sheet using C#?
Sarat Gollapudi
|
|
|
|
|
Dear friends,
I have to write a project that's able to read & write data to an excel file. Just simply like a data base program.
do you have any hints or example?
|
|
|
|
|
I had a big headache trying to do this myself. There may be a way to read and write to a file, but I found I a diffent way to write to Excel, and a different was of reading from, with some help from one of our friends on the CodeProject.
Here is a simple example of writing to Excel. It creates a new Excel book and writes a string in the 1st cell.
/**************************************************/
using System;
using Excel;
using System.IO;
using System.Text;
using System.Data.OleDb;
namespace Writing_to_Excel_example
{
class Class1
{
static void Main(string[] args)
{
bool xlsError = false;
int rowCount = 0;
int counter = 0;
int counter2 = 0;
Console.WriteLine("Working...");
Excel.Application ExcelObj = new Excel.Application();
Excel.Workbook workbook = ExcelObj.Workbooks.Add(Type.Missing);
if (ExcelObj == null)
{
Console.WriteLine("\nERROR: EXCEL couldn't be started!");
xlsError = true;
}
// activate the active worksheet in the workbook
Worksheet ws = (Worksheet)ExcelObj.ActiveSheet;
ws.Activate();
try
{
//To enter text to a specific row and column:
((Range)ws.Cells[1, 1]).Value2 = ("This is Row 1, Column 1");
//To set an entire row as Bold.
((Range)ws.Cells[rowCount, 1]).EntireRow.Font.Bold = true;
}//end try
catch(Exception e)
{
Console.Write(e);
}
//Make Excel visible.
ExcelObj.Visible = true;
}
}
}
/***************************************************************/
DONT FORGET TO ADD REFERENCE TO EXCEL 11.0 OBJECT LIBRARY!!
As for reading from excel, I tried to apply the same sort of logic as above but it didn't work. So have a look at this link:
http://www.codeproject.com/csharp/FasterExcelAccessTOC.asp[^]
Great tips there, a great help to me, Thanks to Dusty Candland, great help mate!!
t-seanm
|
|
|
|
|
Hi!
I need to build/utilize a special printer driver.
Say my printer name is XYZ.
If from any Win Application, I print some document on XYZ, the file must be 'copied' to some specified folder.
This is like a File Copy Agent Printer Driver.
Any info whether there is something like this.
Thanks in advance.
malikware
|
|
|
|
|
Depends on the format you want it to be 'copied' as. There are many PDF print drivers that you can programmatically set (usually through the registry) to dump the printed output to a folder as a PDF file. Check out www.PDFmachine.com for one such example.
|
|
|
|
|
I've searched all over, but I cant for the life of me find anywhere that someone has made (or knows how to make) a button with a drop-down arrow, like the button when you use "Add Existing Item" to a project, the Add button has a dropdown.
Infragistics have a UltraDropDownButton that does this, but it doesn't look like a windows button and I can't get it to.
Any tips?
--
Dave
|
|
|
|
|
Run character map and have a look at the Wingdings and Symbol fonts (I think the drop-down arrow that you're looking for is in Webdings 3). Enter the corresponding character in the button's text field, and set the appropriate font. You'd probably want give the button an "action" part for executing the default, and a "drop-down" part that shows your pop-up menu; so do this as two separate buttons. Putting these on a panel would also be a good idea. For the actual pop-up bit, set up a context menu to pop up when the user clicks on the drop-down button.
|
|
|
|
|
Here is an example from a button control that I created. The drop-down arrow is represented by the number 6 in the Marlett font.
<br />
System.Drawing.Graphics g = this.CreateGraphics();<br />
System.Drawing.Font font = new System.Drawing.Font("Marlett", this.Font.Size);<br />
System.Drawing.SizeF sizeF = g.MeasureString("6", font);<br />
<br />
Brush brush = Enabled ? SystemBrushes.ControlText : new SolidBrush(SystemColors.GrayText);<br />
<br />
g.DrawString("6", font, brush, <br />
Width - 4 - sizeF.Width, (Height - sizeF.Height) / 2.0f);<br />
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|