|
hi
i am writting a writer program that use XPBurncomponent.dll
a pice of code that i used is:
XPBurn.XPBurnCD cd = new XPBurn.XPBurnCD();
cd.AddFile(@"c:\pic1.jpg","pic1.jpg");
cd.RecordDisc(false, true);
but sometimes an error is shown :
error: Exception has been thrown by the target of an invocation
can anybody help me please?
M.Alizadeh
|
|
|
|
|
|
Hi all!!
I have a problem about my project. I want to add tag to files or directories and I have a problem about program start up.
in these code I can get full path but there is some problem about directories name.
For example:
C:\Documents and Settings\*****\Desktop\ListViewExample for this there is no problem
but
C:\Documents and Settings\*****\Desktop\List View Example but if a directory or file name have a space there is a problem occures like that :
C:\Documents and Settings\*****\Desktop\List\View\Example
I could not find a solution with for each too. How can I solve this problem? Thank you very much.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
namespace ARC
{
static class Program
{
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (args != null)
{
string FilePth = "";
for (int i = 0; i < args.Length; i++)
{
FilePth += args[i]+@"\\";
}
MessageBox.Show(FilePth);
if (FilePth != "")
{
parameter.FilePath = FilePth;
Application.Run(new Form1());
}
}
else
{
}
}
}
}
|
|
|
|
|
Any file path that has spaces in must be enclosed in double quotes "c:\ my path\xyz,txt"
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I have am dynamically loading a web user control based on the click of a tab strip
I load the default control for the first tab in the page load event after checking page is not postback. After that the controls are loaded/unloaded based on the SelectionChanged event for the tab strip and again in Page load because with a dynamic load viewstate has to be reloaded. I have a datalist in the user control and I am trying to create the delegate so the parent can handle the click of the edit button in the user control. Honestly I am not very good at event delegation the code complies but I never get the command to execute on the parent
in the child control site.ascx I set up the datalist public event with code below
public partial class Site : System.Web.UI.UserControl
{
public delegate void myItemCommand(object source, DataListCommandEventArgs e);
public event myItemCommand dlSiteItemCommand;
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{ }
protected void dlSite_ItemCommand(object source, DataListCommandEventArgs e)
{
if (dlSiteItemCommand != null)
dlSiteItemCommand(source, e);
}
protected void Page_Load(object sender, EventArgs e)
{ //get the data and fill the datalist }
in the parent (Detail) I try to bind to the event in the Site.ascx When the page loads in the parent the procedure LoadUserControl()
is called and in it after I dynamically load the correct control, I caste the generic control to an instance of Site so I can see the public event I created. Thats where I have got it wrong I am SOOOOO confused. The binding does not work when I click the edit button in the child datalist I never break into the event that is bound on the parent Below is parent code. Please I not this is too long an explanation but I have been trying and reading a long time.
Cindy
public partial class Detail : System.Web.UI.Page
{
private string LastLoadedControl
{
get
{
return ViewState["LastLoaded"] as string;
}
set
{
ViewState["LastLoaded"] = value;
}
}
private void LoadUserControl()
{
string controlPath = LastLoadedControl;
if (!string.IsNullOrEmpty(controlPath))
{
PlaceHolder1.Controls.Clear();
UserControl uc = (UserControl)LoadControl(controlPath);
if (controlPath == "Site.ascx")
{
Site ucSite = (Site)uc;
ucSite.dlSiteItemCommand += new Site.myItemCommand(ucSite_dlSiteItemCommand);
}
PlaceHolder1.Controls.Add(uc);
}
}
void ucSite_dlSiteItemCommand(object source, DataListCommandEventArgs e)
{
(source as DataList).EditItemIndex = e.Item.ItemIndex;
(source as DataList).DataSource = dsTunnel;
(source as DataList).DataBind();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{}
protected void Page_Load(object sender, EventArgs e)
{
if(!(Page.IsPostBack))
{
string controlPath = null;
controlPath = "Site.ascx";
LastLoadedControl = controlPath;
LoadUserControl();
}
LoadUserControl();
}
private void ts_SelectionChanged(object sender, JQD.TabStrip.SelectionChangedEventArgs e)
{
int TabPos = e.TabPosition;
ActiveTab = TabPos;
string controlPath = string.Empty;
switch (TabPos)
{
case 0:
controlPath = "Site.ascx";
LastLoadedControl = controlPath;
LoadUserControl();
break;
case 1:
break;
}
|
|
|
|
|
Trying to use the random() to generate random words from a string[],now I want to put the already picked words in may be an array so that the random() should not pick that word if once picked before.please help
|
|
|
|
|
Random helper class...[^]
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Thats was really a great prog.
Now check here, am generating a random word from an array which I display on the textbox in form of stars for the user to guess.Now I don't want the user to come across the same word again.How can I please go about it to make the random method not to get the same word again.Like the way Hung man game operates
waiting......
|
|
|
|
|
Read the question before you reply. It's not helpful to post your self-promoting links if they don't apply to the question at all.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
If you do that, you have to loop when you try to find an unused word. Instead, put the words in a list, and remove the words that are picked:
List<string> words = new List<string>(arrayOfWords);
Random rnd = new Random();
int index = rnd.Next(words.Count);
string pickedWord = words[index];
words.RemoveAt(index);
Despite everything, the person most likely to be fooling you next is yourself.
modified on Sunday, September 7, 2008 11:17 AM
|
|
|
|
|
That was quiet penetrating, which namespace do I use for Lists. Is it an ArrayList or SortedList you are talking about(am familiar with these System.Collections;, System.Text;)?
|
|
|
|
|
The List<T> class is in the System.Collections.Generic namespace.
Unless you are stuck with framework 1.x you should not use ArrayList at all.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks.
Unfortunatly, am only able to program on one form.How about having multiple forms and calling them interchangebly.
|
|
|
|
|
MorganSim wrote: Unfortunatly, am only able to program on one form.How about having multiple forms and calling them interchangebly.
I don't see how this relates to the original question at all? Can you clearify?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hello people!!!
was just trying to see what else the internet can provide to the real world, unfortunatly, I arrived down to this site.It must be great site.
Am just new into C# programming, no much exprience, I would love to be given to write a simple program just to test how far I can go with C#.Please help,send back specifications for a small program I must write.Please!!
|
|
|
|
|
Check this link.[^]
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
|
|
That was another good start on a different part of C#, it was clear enough. How about getting a little deeper, can you supply some more?.Lets say trying to write a running program......
Hala
|
|
|
|
|
I don't know in which area of C# programming you are interesting to learn! But it is better by yourself to sign on google and search what first comes in your mind about programming.For any specific question sure you can ask here and CP members with pleasure will answer to you.
Regards.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Thanks.
Ok, this far I can only write and design a program using one form, how can I have more than a form and call them inter-changebly?am kinda struggling with this as of now.
|
|
|
|
|
I have a client that make a RPC to a server, "singlecall", and after the proxy is created that client makes one call back to the object that is on the server.
When called the server object creates a new process and starts cmd.exe. It then makes a query to the local DNS server to check for availability for a node record in a zone. Basically I need to know if a node exists inside a zone.
In development this works great, and after working with this for over a week I am almost sure that I know the deal now. This has to be a security issue. I believe that the new process that is created on the server be the server object is running in to low of privileges to make a call to the DNS server.
I know the RPC is a success because I write line to the console window every time a request is made from the client. The second request from with-in the server object to the new process is the one that is not a success.
How do I set permissions from a situation like this?
Below is my server object. "The one that needs the permissions set"
---------------------------The instantiation is successful
public AFCCDnsManager()
{
Console.WriteLine("Request from client just came in");
}
------------This is the method that needs help. "Works great in development"
public bool CheckIfDomainZoneNodeHasRecords(string server, string zone, string node)
{
Process myProcess = null;
ProcessStartInfo myProcessStartInfo = null;
StreamReader myStreamReader = null;
string cmdFailed = string.Empty;
string dnsCmd = string.Empty;
string output = string.Empty;
try
{
cmdFailed = "DNS Server failed";
//string cmdCompleted = "command completed successfully";
//Command failed: DNS_ERROR_NAME_DOES_NOT_EXIST 9714
//cmd server cmd zone node
//dnscmd afcc-inc-ns1 /enumrecords AFCCINC.COM handlers
dnsCmd = string.Format("dnscmd {0} /enumrecords {1} {2}", server, zone, node);
output = string.Empty;
myProcess = new Process();
myProcessStartInfo =
new ProcessStartInfo("cmd.exe");
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.CreateNoWindow = true;
myProcessStartInfo.RedirectStandardOutput = true;
myProcessStartInfo.RedirectStandardInput = true;
myProcessStartInfo.Arguments = dnsCmd;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
myStreamReader = myProcess.StandardOutput;
myProcess.StandardInput.WriteLine(dnsCmd);
char[] blockOfChars = new char[356];
myStreamReader.ReadBlock(blockOfChars, 0, 355);
myStreamReader.Close();
myProcess.Close();
output = new string(blockOfChars);
if (output.ToLower().Contains(cmdFailed.ToLower()))
{
return false;//0
}
else return true;
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message);
}
finally
{
myProcess = null;
myProcessStartInfo = null;
//myStreamReader = null;
cmdFailed = string.Empty;
dnsCmd = string.Empty;
output = string.Empty;
}
}
Thank you for your help
Erik
|
|
|
|
|
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I was able to finally get this to nightmare to work.
This is so weird because I would have thought that all I needed to do would be do a .ReadToEnd(); but this just made
the app hang up.
So I have had to do this see saw type of push pull the stream until I get the data that I am looking for.
public bool CheckIfDomainZoneNodeHasRecords(string server, string zone, string node)
{
//
Process myProcess = null;
ProcessStartInfo myProcessStartInfo = null;
StreamReader myStreamReader = null;
string cmdFailed = string.Empty;
string dnsCmd = string.Empty;
StringBuilder output = null;
try
{
cmdFailed = "DNS Server failed";
//string cmdCompleted = "command completed successfully";
//Command failed: DNS_ERROR_NAME_DOES_NOT_EXIST 9714
//cmd server cmd zone node
//dnscmd afcc-inc-ns1 /enumrecords AFCCINC.COM handlers
dnsCmd = string.Format("dnscmd {0} /enumrecords {1} {2}", server, zone, node);
output = new StringBuilder();
myProcess = new Process();
myProcessStartInfo =
new ProcessStartInfo("cmd.exe");
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.CreateNoWindow = true;
myProcessStartInfo.RedirectStandardOutput = true;
myProcessStartInfo.RedirectStandardInput = true;
myProcessStartInfo.Arguments = dnsCmd;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
myStreamReader = myProcess.StandardOutput;
do
{
output.Append(myStreamReader.ReadLine() + "\n");
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine(dnsCmd);
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine("\n");
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine("\n");
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine("\n");
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myStreamReader.Close();
myProcess.Close();
Console.WriteLine(output.ToString());
if (output.ToString().ToLower().Contains(cmdFailed.ToLower()))
return false;//0
return true;
}
catch (Exception ex)
{
System.Net.Mail.MailMessage mm = null;
SmtpClient smtp = null;
mm =
new System.Net.Mail.MailMessage
(new System.Net.Mail.MailAddress("problems@afccDnsManager.com"),
new System.Net.Mail.MailAddress("support@afccinc.com"));
//
mm.Subject = "Problems with the AFCC Dns Manager Service";
mm.Body = "Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine;
mm.Body += "Source : " + Environment.NewLine + ex.Source;
smtp = new SmtpClient("smtp.afccinc.com");
smtp.Send(mm);
mm = null;
smtp = null;
//
return true;
}
finally
{
myProcess = null;
myProcessStartInfo = null;
myStreamReader = null;
cmdFailed = string.Empty;
dnsCmd = string.Empty;
output = null;
}
}
Any suggestion?
http://storefrontdoors.net
Erik
modified on Thursday, April 9, 2009 5:19 PM
|
|
|
|
|
Hi, I am trying to append text to a textbox in a form after clicking a button in another form. How do I access the textbox from the button click method?
Thank you.
|
|
|
|