|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
Is there a way to exclusively identify email-enabled public folders using Microsoft.Office.Interop.Outlook? EWS or PowerShell should not be used. The program should run on the workstation and utilize the installed Outlook.
Once I've found an email-enabled public folder, I should list the emails contained within it.
So far, I'm encountering difficulties. For instance, I have the following method:
static void ListPublicFolders(Outlook.Folder? folder, string indent)
{
if (folder != null)
{
foreach (object obj in folder.Folders)
{
if (obj is Outlook.Folder)
{
Outlook.Folder? subFolder = obj as Outlook.Folder;
if (subFolder != null && subFolder.DefaultItemType == Outlook.OlItemType.olMailItem)
{
Outlook.MAPIFolder? parentFolder = subFolder.Parent as Outlook.MAPIFolder;
string parentName = parentFolder != null ? parentFolder.Name : "Parent folder not found";
Console.WriteLine($"{indent}- {subFolder.Name}: {parentName}");
if (parentFolder != null)
{
Marshal.ReleaseComObject(parentFolder);
}
}
ListPublicFolders(subFolder, indent + " ");
if (subFolder != null)
{
Marshal.ReleaseComObject(subFolder);
}
}
}
}
}
The query
if (subFolder != null && subFolder.DefaultItemType == Outlook.OlItemType.olMailItem)
fails because subFolder.DefaultItemType returns the value Outlook.OlItemType.olPostItem, even though the public folder was set up as an email-enabled folder in Exchange.
Specifically, this is in Microsoft 365. In the Exchange admin center, when creating the folder, I explicitly checked the box for "Email-enabled." This action resulted in two additional options: "Delegation" and "Email properties." In "Email properties," I can specify an alias and a display name. By default, both fields are set to "Orders." Now, I expect the public folder to be email-enabled, with the email address orders@domain.tld.
I don't understand why Outlook is treating the folder incorrectly (I can only create posts and not send emails).
Perhaps someone can help me figure this out.
Thank you and best regards,
René
|
|
|
|
|
Hi All,
Stupid Question time. If a value is read to a textbox it is a String, to convert it to a value in the past I have done:
int Value = 0;
Value = Convert.ToInt16(textBox1.Text) I'm sure of it and then done maths and operations on the Value such as:
if(Value > 1000)
{
MessageBox.Show("Here!");
} But it won't run in VS2022 it returns a System.Format.Exception error. What have I done?
Glenn
modified 9-May-24 10:29am.
|
|
|
|
|
Don't use Convert as any error in the format of the input string will cause an exception.
Instead use int.Parse because you can check the result of the parse operation to see if you have entered a valid or invalid string.
From memory you should do the following
if (int.Parse(textBox1.Text, out int result))
{
}
else
{
}
|
|
|
|
|
You mean TryParse ; Parse returns the parsed value or throws an exception.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I checked that twice and still missed that (Doh)
|
|
|
|
|
What value is in the textbox? If it can't be parsed as a short using the current culture settings, then Convert.ToInt16 will throw an exception.
You should use TryParse[^] rather than the Convert method to avoid the "can't parse this" exception:
if (int.TryParse(textBox1.Text, out int value))
{
if (value > 1000)
{
MessageBox.Show("Here!");
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hmmm, I'm reading back a sensor, it's giving values all over the show!
private void button1_Click(object sender, EventArgs e)
{
if (int.TryParse(textBox1.Text, out int value))
{
if (value > 1000)
{
MessageBox.Show("Here!");
}
MessageBox.Show(value.ToString());
}
MessageBox.Show(value.ToString());
}
value is taken as 0, despite textBox1.Text having 1234.56...
|
|
|
|
|
glennPattonWork3 wrote: despite textBox1.Text having 1234.56... But 1234.56 is a Float/Double not an Int ; the two are quite different.
|
|
|
|
|
You are right, but even if make 1234 it still returns a 0...
|
|
|
|
|
Come on Glen, you need to show us the exact code, and the exact text that you are using.
|
|
|
|
|
Hi,
This is the code I have been trying to get all afternoon!
private void button1_Click(object sender, EventArgs e)
{
float ForceVal = 0;
<pre>
decimal.TryParse(weightTxt.Text, out decimal value);
if (value > 1000)
{
MessageBox.Show("Here!");
}
MessageBox.Show(value.ToString());
}
I think that should do it. I'm hacking together a test program that interfaces to a Phidget load cell in trying to measure a value that needs to converted to Newtons from Grams (I think!). I hate the fact I wasted so much time trying to get the value to be used out of a darned label. I haven't really done much Windows code (I'm an embedded guy really) since VS2008 was the new kid on the block and times like these it shows!
|
|
|
|
|
Did the TryParse call succeed, return true?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Sort of I had to:
decimal.TryParse(weightTxt.Text, out decimal value);
as I was messing with a floating point number, haven't coded in Windows for a while, man it shows!
|
|
|
|
|
Maybe try decimal.TryParse()? as the input is not an int.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Thanks, that appears to work!
|
|
|
|
|
Good news!
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
I have tried to pass command line arguments to IrfanView to rotate a image, the code is below, the commented code works without a problem. The problem is the uncommented code, when the process is started, there are no errors but no changes are made to the image. I have tried the proper syntax code in VB.NET and it works as expected, any insight as to what's wrong?
//args = file1 + " " + "/rotate_r " + "/convert=" + file2 + "/killmesoftly";
//args = " " + file1 + " " + "/rotate_r " + "/jpgq=100" + "/convert=" + file2 + "/killmesoftly";
args = " " + file1 + " " + "/jpg_rotate=(3,1,0,1,0,0,0,0)" + "/killmesoftly";
|
|
|
|
|
I don't know why newbs always insist on breaking up what should be a single string into a bunch of string concatenations, making it harder to debug your code. You can do this all in one string:
args = $"{file1} /jpg_rotate=(3,1,0,1,0,0,0,0) /killmesoftly";
Take a closer look at your uncommented code:
args = " " + file1 + " " + "/jpg_rotate=(3,1,0,1,0,0,0,0)" + "/killmesoftly";
This will result in an arguments string that looks like this:
[file1]
Notice there is no space before the /killmosoftly switch. That will probably generate an error for the Irfan command.
modified 7-May-24 23:37pm.
|
|
|
|
|
Dave;
Thank you for responding, unfortunately the image was not rotated. As I stated previously the string works in Excel VBA & VB.NET with the correct file location syntax.
Thanks again for your help
|
|
|
|
|
I didn't say I knew anything about Irfan, only that your code is unnecessarily complicated, making it harder to debug.
|
|
|
|
|
Adding to Dave's wise words, your uncommented string doesn't specify an output file, so it may very well execute the process and discard the result.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Peter;
Thank you for responding. There is no switch for an output file, because the original file is overwritten.
|
|
|
|
|
Hi everyone,
hard to phrase a title for what i am looking for, therefore following explanation.
I have the requirement to establish communication to a device via Secure WebSockets using TLS 1.3 and need to research on how i can do that from our applications that sadly are running with .NET Framework 4.0.
What i found out yet is that it might be a pain to get Secure WebSockets with TLS 1.3 running with that old framework and therefore i need to find a proper solution on how to circumnavigate this issue.
My Idea:
The old application will talk with a service / server specifically designed to just do the communication part, meaning the old stuff doesn't get touched and the service can run with .NET 8, which obviously should support the requirement.
What my questions are:
Does anyone have an idea or can point me into the right direction in terms of:
- How do they both communicate with each other (I would prefer not to use any COM stuff if possible)
- What type of project to use for the .NET 8 app?
--> I heard of the "Worker services in .NET" which seems the right thing to me, since the "service" needs to be run on demand (Only if required to be used), should support multiple connections and should not show stuff on a console while running.
Since the idea is to have a "secure" connection it would be strange if all the info can be read via COM communication. On the other hand that's a fairly new area for me, so i have no clue if that is just the way to go and does work "secure" as well. My head just says COM sounds old and may be wrong, but don't hate me for that
Additionally:
Regarding installation or installation of a "Service" there won't be much of issue afaik, in the end the user simply doesn't care, shouldn't know or bother how the magic works behind the UI.
Many thanks in advance!
Rules for the FOSW ![ ^]
MessageBox.Show(!string.IsNullOrWhiteSpace(_signature)
? $"This is my signature:{Environment.NewLine}{_signature}": "404-Signature not found");
|
|
|
|
|