|
I see a little problem with saving from msWord back to original.
The file is opened all right, but in read-only.
How do I change this?
Sorry for my lack of knowledge... but this things are a bit new to me.
|
|
|
|
|
Do the user under which is running your program have write privileges over the file?
Can you open it by hand (eg. open Word and then open the html file) and save it?
|
|
|
|
|
Yes, If I open it by hand, it is saving ok, loading ok... I am the only user and I have all the privileges over the file R&W.
|
|
|
|
|
Does your app (that contains the Process.Start stuff) do something else with the same .doc path, something Stream-like, File-like, FileInfo-like? If so, did you Close() and Dispose() it properly before calling Process.Start()?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Yes, it opened the file... and I was not disposed it. Now is working correct.
Thank you.
|
|
|
|
|
I'm trying to get a WCF service up and running inside a Windows Service. The WCF service is supposed to troll for messages (xml) in a queue, adapt the xml message body to one of our business objects, and toss the object down the architecture as if it were just any other <insert>.
I worked through the installation earlier this morning (wasn't running command line as Administrator...remember to do that lol) but now, when I attempt to start my service, it pops up and gives the familiar
<Foo> service on <machine> started and then stopped. Some services stop automagically if they are not in use by other services or programs.
I don't think I'm doing anything fancy, at all. I'm just trying to get the thing to fire up and possibly see a message dropped on the queue get picked up by our WCF service, adapted, and inserted into our database.
I'm not really all that experienced with WCF services though...and come to think of it, I don't think I've actually created a Windows Service since college...and it seems as if Google does not know this answer or I'm phrasing my searches incorrectly.
Here's my Windows Service code.
public partial class LoggingWinService : ServiceBase
{
public ServiceHost host = null;
public LoggingWinService()
{
ServiceName = "LoggingServiceSample";
InitializeComponent();
}
public static void Main()
{
ServiceBase.Run(new LoggingWinService());
}
protected override void OnStart(string[] args)
{
if (host != null)
{
host.Close();
}
host = new ServiceHost(typeof(LoggingWCFService));
host.Open();
}
protected override void OnStop()
{
if (host != null)
{
host.Close();
host = null;
}
}
}
...help?
"I need build Skynet. Plz send code"
modified on Friday, May 20, 2011 12:07 PM
|
|
|
|
|
...hmmm. Seems I jumped the gun a bit on throwing up a flag asking for help. I had checked the Application Logs in the EventViewer for information, saw nothing reported for my service, and continued digging elsewhere for a solution. Apparently, I had read the logs incorrectly and erroneously dismissed them in my process. Although I'm not completely up and running yet (have yet to test the queue feed), it seems as if my initial problem was due to my accidental decoration of an endpoint with a behavior when I intended that behavior to tag the service itself.
Upon further investigation, pulled the following from Application Log in the EventViewer:
Service cannot be started. System.Configuration.ConfigurationErrorsException: There is no endpoint behavior named 'metadataBehavior'.
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
at ...
(metadataBehavior is a service behavior, not an endpoint behavior)
"I need build Skynet. Plz send code"
|
|
|
|
|
Hi ,
I have an application to split images using c#. The problem im facing is that i need the images to be compressed and saved to .ica readable format. I have tried most of the common compression types and have not succeeded.
Any help would be appreciated. Thanks
|
|
|
|
|
ICA is an image format Citrix came up with and stands for Independent Computer Architecture.
I don't know of any libraries that will convert an image to this format. You may have to get with Citrix to see if they have something to help you.
|
|
|
|
|
Hello
How can i create one button for two events?
For example: I want to have one button for start/stop.
At the beginning of the application button name is start (start the event ), when I click the button second time it change the name to Stop (stop the event)????
I am very new to C# programming, i know to do this in VB6... Sorry for my bad english!
ThankYou
|
|
|
|
|
You can just create 2 event handlers one called Stop, the other Start and just swop between the 2, something like this
void Stop(object sender, RoutedEventArgs e)
{
button1.Click -= new RoutedEventHandler(Stop);
button1.Click += new RoutedEventHandler(Start);
button1.Content = "Start";
}
void Start(object sender, RoutedEventArgs e)
{
button1.Click -= new RoutedEventHandler(Start);
button1.Click += new RoutedEventHandler(Stop);
button1.Content = "Stop";
}
Initially the Click event would be set to Start().
Hope this helps
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
Ok understand that. But now i have problem to call this voids in
private void btnstart_Click(object sender, EventArgs e)
{
if (button1.Content = "Start")
{
}
else
{
}
}
I get error:The type or namespace name 'RoutedEventArgs' could not be found (are you missing a using directive or an assembly reference?)
|
|
|
|
|
OK, my error, I assumed you were using WPF not WinForms,. Here is the correct version
private void Start(object sender, EventArgs e)
{
button1.Click -= new EventHandler(Start);
button1.Click += new EventHandler(Stop);
button1.Text = "Stop";
}
private void Stop(object sender, EventArgs e)
{
button1.Click -= new EventHandler(Stop);
button1.Click += new EventHandler(Start);
button1.Text = "Start";
}
Sorry about that!
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
A singe event with an if statement should solve your purpose. Why do you need two events?
private void button1_click(object sender, EvenArgs e) {
if (button1.Text == "Start") {
button1.Text = "Stop";
} else {
button1.Text = "Start";
}
}
I am assuming that you're doing the job in a different thread or a BackgroundWorker .
|
|
|
|
|
I was thinking the same.Write two methods and handle it in that single event click.
|
|
|
|
|
As an aside (ish):
Please please please don't use the button text to work out what state you're in, use something like a boolean member variable instead (or, if you absolutly must use a property on the button, something like the Tag property). The code snippet you've given will break as soon as you try to localise your application, and just really isn't good practice.
Something like:
private bool started = false;
private void button1_click(object sender, EventArgs e) {
if (!started) {
button1.Text = "Stop";
started = true;
}
else {
button1.Text = "Start";
started = false;
}
}
Also, if you're working in a different thread, don't forget cross-thread access issues.
|
|
|
|
|
I know that Tony, I was just giving him a heads up on where to start. His question was very basic and I did not want to confuse him with the specifics. Anyway, thanks for the tip.
|
|
|
|
|
If you're going to use the localisation argument then surely you should set the button text to resource strings
I like to use Tag for this, unless I am already using it for something else, as it really is a property of the button and should be stored with it.
Of course in most cases the button is controlling the state of some business object and you should check that instead:
private Task someBigJob;
private void button1_click(object sender, EventArgs e) {
if (someBigJob == null || !someBigJob.Running) {
button1.Text = "Stop";
someBigJob.Start();
}
else {
button1.Text = "Start";
someBigJob.Stop();
}
}
(for the benefit of the OP, I'm sure you know already!)
|
|
|
|
|
I've done that, I won't do it again; I'd create two Buttons but have only one visible at a time.
|
|
|
|
|
Can you tell us why ?
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
Wayne Gaylard wrote: Can you tell us why ?
Because its just a better way of doing it.
Because it avoids the previously mentioned problem of using the button's text to determine what to do, with all the inherant problems associated with using this method.
Because the 2 buttons do a different job and therefore should not be the same button (separation of concern)
I could go on.
|
|
|
|
|
Now this is an interesting thread. I don't agree with you that it's a better way to do it, because it comes with other problems (you have to manually place two buttons in the same place, make them the same size, tab order and keyboard mnemonic, etc).
If you want to have it look like one button, then make it one button. (Of course a Start and Stop button next to each other is also acceptable.)
I would say that the button does one single job: it toggles the state of the underlying thing that is being started or stopped. Logically, one might make it a check box, but users don't expect that.
|
|
|
|
|
J4amieC wrote: Because its just a better way of doing it.
It's just a different way of doing it. There's this thing called a ToggleButton[^].
I wouldn't use a button, but a checkbox. Makes it clear to the user that there are two different states, and that it toggles.
J4amieC wrote: Because the 2 buttons do a different job and therefore should not be the same button (separation of concern)
If they're calling the same method, one with a boolean "true" and the other with "false"? The world isn't that black-and-white.
Bastard Programmer from Hell
|
|
|
|
|
I could, but J4amieC did a good enough job.
|
|
|
|
|
thank you
solve my problem with this:
If (txtstart.text="OK")
{
do somthing
}
else if (txtstart.text="Stop")
{
application.close();
}
|
|
|
|