|
Thanks for that, keep up the good advice....
|
|
|
|
|
You still don't understand that comparing 1 to true would still return false anyway. So it is irrelevant whether CompareTo would return 0, 1 or PI, the result would always be false in your case.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi Greeeg,
thanks for taking the time to post, yeah your right, I was just expecting it to return 1 (true),
I was just curious, but after alans post made me look on MSDN, so it would be more like
if (i.CompareTo(ii).Equals(0)) ((0\1)and not true\false)
thanks tho.
|
|
|
|
|
good morning people, can someone tell me how can i adjust a pc's UTC by code?
|
|
|
|
|
You mean the time zone? Why would you need to? That shouldn't be done by software.
|
|
|
|
|
PIEBALDconsult wrote: That shouldn't be done by software.
Absolutely, the only legal way to change time zones is by traveling. There's nothing virtual about that.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:36 AM
|
|
|
|
|
Well, no, I can set my system to any time zone I want. But I don't want some program to do it without my knowledge and approval.
|
|
|
|
|
There may be other methods but try looking at WMI.
This article[^] might be a good starting point.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
thanks man, thing is im using amazon simple storage service and when im making request (downloading/uploading objects) on a particular pc i get a 403 forbidden error, i have tried on many other computers and theres no problem, so i asked and they told me if my utc was off by more than 15 min it would give me this error, i checked utc on it and it was in fact very different than mine so i wanted to start there
|
|
|
|
|
That is a different problem!
That is a question of getting your PCs internal clock synchronised to a local Time-Server. This is one of the settings in Control Panel and it does it at a period you set when you connect to the Internet, unfortunately I cannot remember exactly where it is off the top of my head. Google for 'Time-Server AND sychronise'. That should get you sorted.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
i wanted do know how to fix it by code because i cant go to every pc thats gonna use this stuff and manually do it if this issue presents itself again,thanks man ill start there
|
|
|
|
|
If your clock is off, just set it.
|
|
|
|
|
i thinks its a little harder than that haha, my clock is good, the clock on the machine where im having problems is fine too, but when i do UTC.now i get different utc times on both mine and the troublesome computer, s3 works in my pc so i figured it was the other computer with an off utc
|
|
|
|
|
They're both set to the same time zone and display the same local time, but you get different UTC times?
|
|
|
|
|
yeah man i ran the exe in both computers, my utc was 7 hours later than my actual time, the other computer was 8 hours later than its actual time so the other pc got the forbidden error, weird right?
S3 will give you a 403 forbidden error if your utc time is off by more than 15 min, the computer from hell was off by an hour, no wonder it gave me the 403
|
|
|
|
|
|
well probably, the computer was recently formatted (sp?) and before that the exe worked perfectly, but theres gotta be a way of solving this without going manually into the computer itself, what if more computers present this problem?
|
|
|
|
|
If they're within a company, can't the system administrators set them administratively?
|
|
|
|
|
I have written a c# app which creates folders and imports files into a doc library. I would like to change the value of the Title property of these folders and documents to something meaningful to my users. The most recent ways I've tried are:
SPFile newdoc = folder.Files.Add(folder.Url + "/" + SPFileName, content, true);
SPListItem doc = newdoc.Item;
doc["Title"] = "whatever";
doc.SystemUpdate();
and
SPFile newdoc = folder.Files.Add(folder.Url + "/" + SPFileName, content, true);
Hashtable hashes = newdoc.Properties;
hashes["Title"] = title;
newdoc.Update();
Neither changed the title property of the document. I didn't get any errors, it just didnt' do what I wanted.
How can I change the title property that displays in the document library for a document?
|
|
|
|
|
hi,
i connected 2 computers with COM cable (RS232).
i created 2 application for sending and receiving information.
i tried to send information from the first computer and to see it at Listen32 program on the other computer. I get the information correctly with [CR] and [SP] -(that what i wants) .
But In my receiving application i get information without these ( [SP] [CR]).
how can i change the Encode and to get information with [SP] and [CR]?
My Sending Application
namespace WindowsFormsApplication14
{
public partial class Form1 : Form
{
SerialPort port;
public Form1()
{
InitializeComponent();
port = new SerialPort("COM1", 2400, Parity.None, 8, StopBits.One);
port.Open();
}
private void button1_Click(object sender, EventArgs e)
{
port.Write(textBox1.Text);
}
private void button2_Click(object sender, EventArgs e)
{
port.Close();
}
}
}
my receiving application
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
private SerialPort p = new SerialPort("COM1", 2400, Parity.None, 8, StopBits.One);
public Form1()
{
InitializeComponent();
CheckForIllegalCrossThreadCalls = false;
Thread t = new Thread(new ThreadStart(SerialPortProgram));
t.Start();
}
public void SerialPortProgram()
{
p.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
p.Open();
Application.Run();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
textBox1.Text += p.ReadExisting();
}
|
|
|
|
|
Hi,
what is the problem? what are those [SP] [CR] you speak about?
Admin887 wrote: CheckForIllegalCrossThreadCalls = false;
don't ever do this, it means you want to ignore a fundamental flaw in your code and hope it will
work. Well, it will not. The right thing to do is make sure you touch controls only from inside
the main thread; all other threads need to use the Control.InvokeRequired/Control.Invoke pattern.
Look it up, it isn't hard to do it right.
Admin887 wrote: Application.Run();
What is this statement doing there? throw it out!
Admin887 wrote: Thread t = new Thread(
Why do you start another thread, all it does is open the serial port, you could have done that
in the form's constructor (or in its Load handler). DataReceived will be called on yet another
thread anyway, one you do not control at all (like most asynchronous operations in .NET).
In summary: clean up the code, and research Control.InvokeRequired.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
first of all, thank you for your attention.
[SP] (space in ASCII)= means that there is space in line
[CR] (New row in ASCII)= means that there is a new row
for example this line:
I am going to show you something
i want to get:
I[SP]am[SP]going[SP]to[SP]show[SP]you[SP]something[CR]
while reading from the port,i get the information in one row. i want to separate and to know when a row is ends- [CR].
i know that there is method port.readline() but the application stucks on this line.
maybe there is another solution to know where the line is ends.
(i means, when i send two lines to the port from the first computer - on the second computer, i get 1 long row).
there is another way to solve it?
|
|
|
|
|
Hi,
Admin887 wrote: [SP] (space in ASCII)= means that there is space in line
[CR] (New row in ASCII)= means that there is a new row
That's what I assumed, but I needed to be sure.
If you are saying text is coming through correctly except for those two characters, then I admit
I know of no reason why spaces would not work as intended.
There are a few things you should be aware of:
1. serial ports transmit bytes, not characters.
2. .NET strings consist of characters, and Unicode characters at that (16-bit wide).
3. The SerialPort class translates characters to/from bytes using an Encoding; it has an Encoding
property for that purpose, it is said it defaults to ASCII, but IIRC it works better when you set
it explicitly, don't know why that is. And you might want to use code page 1252 so you get
8-bit ANSI characters (including some accented characters, trademark, copyright, euro, etc)
rather than just the 7-bit ASCII set
4. SerialPort.ReadLine() waits for an end-of-line, which is defined through the NewLine property.
AFAIK that is set to [CR][LF] by default (actually to Environment.NewLine). So as long as that
exact sequence of characters isn't seen, there is no new line starting.
5. Your sending program isn't really sending any NewLine sequences, is it? it is rather difficult
to enter them manually in a textbox. What you could do is transmit textbox.Text+Environment.NewLine
though.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:37 AM
|
|
|
|
|
Hi,
I suggest you add some logging to your sending application to determine what you actually writing to the port. You can then view the log file with a hexadecimal editor and assure yourself that you are sending the correct sequence of bytes.
If the file is as expected you could do something similar at the receiving end.
private void button1_Click(object sender, EventArgs e){
System.IO.File.AppendAllText("log.txt", textBox1.Text, port.Encoding);
port.Write(textBox1.Text);
}
Alan.
|
|
|
|
|
Hi,
I like that very much.
I would even add a label showing the hex values of the bytes that get transmitted at the sender,
and received at the receiver PC.
Observability is key in debugging.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:37 AM
|
|
|
|
|