|
Is it possible to copy a file using .NET where the path is greater than 248 characters? If not, are there any work arounds?
|
|
|
|
|
Before asking this question you should atleast try this I hope this will work.
Use File.Copy() Method
Best Regards,
Rizwan
|
|
|
|
|
This is what I use but my path contains more than 248 characters which throws a System.IO.PathTooLongException exception. I was wondering if there was any way around this.
|
|
|
|
|
Have you tried
FileInfo f = new FileInfo(LongPath);
f.CopyTo(NewLocation);
|
|
|
|
|
Yes - it throws the same exception.
|
|
|
|
|
hello friends,
I want to get a handle to the currently open instance of the microsoft word. I got that successfully but after that I want to get the inputstream to that process (word). I found method for that but I am getting an error at that statement. my code is as under. someone please give me some suggestion. also let me know if I am doing it in a wrong way.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Windows;
using System.IO;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = "C:\\Program Files\\Microsoft Office\\OFFICE11\\WINWORD.exe";
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.Start();
StreamWriter sw = p.StandardInput;
sw.WriteLine("This is a test");
Process[] procs = Process.GetProcesses();
foreach (Process proc in procs)
{
if (proc.MainWindowHandle.ToInt32() != 0)
{
if (proc.ProcessName == "WINWORD")
{
System.Windows.Forms.MessageBox.Show(proc.Handle.ToString());
StreamWriter myStreamWriter = proc.StandardInput;
myStreamWriter.WriteLine("This is a Test");
}
}
}
}
}
-vaishnav hardik
|
|
|
|
|
Where did you see that MS Word will process data from the input stream?
|
|
|
|
|
Hi guys,
In my title bar title text I have my application name and then next to it I would like to put TM, in very small letters. How can I do that?
Please help
sasa
|
|
|
|
|
Open up Microsoft Word, Choose Insert --> Symbol.
Select the 'TM' symbol
Copy it
Paste it in the TEXT property of your form.
This is the 'non technical' way of doing it
|
|
|
|
|
If you don't have word, use charmap isntead.
|
|
|
|
|
Problem is already solved What can I do now
|
|
|
|
|
Hi All !
I want to get a Sum after Filtering some special record , for example [price] is a field in my Table1 .
strFilter="SELECT price From Table1 WHERE City='Athen'";
After filtering with this Query in my Report , I want to get a Sum for the all price related for City='Athen' and I show it in a Label .
Thanks A lot ,
Regards ,
s_mostafa_h
|
|
|
|
|
You can create a running total field or a function. If you just want the sum
SELECT sum(price) as sumOfPrice FROM table WHERE city='Athen'
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
thanks
infact :
strFilter="SELECT sum(price) as sumOfPrice FROM table WHERE city='"+txtCity.Text+"'";
I want to put the result of this query in a Label .
s_mostafa_h
|
|
|
|
|
I don't know if your particular application is subject to this but it is always wise to use stored procedures or at the very least parameterization of your query.
SELECT sum(price) as sumOfPrice FROM table WHERE city = @city;
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
thanks for ur patient ,
I'm very ,
Crystal Report simply provide this .
s_mostafa_h
|
|
|
|
|
Hello Devs,
I'm developing a Chat application and I'm facing a problem. I have the following Method which is called from multiple threads. And when I start sending too much messages in speed (which invokes this method so fast) then client is disconnected. Let me show you the method and then continue my discussion:
public void SendMessage(TextMessage messageToSend)<br />
{<br />
try<br />
{<br />
lock (this.dataStream)<br />
{<br />
byte[] serializedBytes = messageToSend.GetBytes();
byte[] encMessageBytes = encryptorDecryptor.Encrypt(serializedBytes);
serializedBytes = null;<br />
int messageSize = encMessageBytes.Length;<br />
byte[] messageSizeBuffer = new byte[this.messageDataLengthBufferSize];<br />
messageSizeBuffer = BitConverter.GetBytes(messageSize);<br />
this.dataStream.Write(messageSizeBuffer, 0, this.messageDataLengthBufferSize);
this.dataStream.Write(encMessageBytes, 0, messageSize);
this.dataStream.Flush();<br />
messageSizeBuffer = null;<br />
encMessageBytes = null;<br />
}<br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
string str = ex.Message + "\n" + ex.StackTrace;<br />
Disconnect();<br />
if (Disconnected != null)<br />
{<br />
Disconnected(this, EventArgs.Empty);<br />
}<br />
}<br />
}
In my opnion, the cause of this problem is multi threaded environment or it overflows data when i start sending to fast. for example if it is already working to send data on NetworkStream then a new call to this method is made which passes a new object of TextMessage to it which over writes the existing one so it is all messed up.
Note: Actual exception I get on the receiving end when length of data is not one which is supposed to be. See the code for Receiving:
int messageSize = BitConverter.ToInt32(messageDataLengthBuffer, 0);<br />
MemoryStream memstrm = new MemoryStream();<br />
<br />
readByteCount = 0;<br />
while (messageSize > 0)<br />
{<br />
readByteCount = dataStream.Read(this.messageDataBuffer, 0, messageDataBuffer.Length);<br />
if (readByteCount < 1)<br />
{<br />
Disconnect();<br />
return;<br />
}<br />
memstrm.Write(this.messageDataBuffer, 0, readByteCount);<br />
messageSize -= readByteCount;<br />
}<br />
memstrm.Position = 0;<br />
<br />
byte[] decryptedData = encryptorDecryptor.Decrypt(memstrm.ToArray());<br />
receivedMessage = new TextMessage(decryptedData);<br />
<br />
memstrm.Close();<br />
memstrm = null;
On the receving end I read 4 bytes as a size of incoming message then loop the piece of code to get all data untill complete message is received as of the message size. So when i start messages too fast then at the end of the loop "messageSize" usually gets in -ve which must never be less than 0 and when i try to get data decrypted again, it throughs exception "Length of data is invalid".
Is there any way that i can implement a mechanism that if SendMessage is doing its work then it should not be called again untill its done with its existing work? Or any other way to solve this issue?
Its really urgent. Any help will be really appreciated!!!
Best Regards
|
|
|
|
|
I assume that this.dataStream is the stream you are sending? If so better to create a queue of messages to send and then have a thread loop through the queue. Best part is that you will have a minimum of fuss.
private void AThreadedMethod(){
while(go){
if(queue.Count >0){
someObject = queue.Dequeue();
... do your stuff here
}
}
}
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Thanks for reply, Yes dataStream is an object of NetworkStream. I can understand the mechanism of Queing the messages but creating 100 threads for 50 Clients(50 on client end and 50 on server end) will seriously do a rape with CPU;P. One easiest way to solve this problem is to put Thread.Sleep(50); above each call of this method. Which will also not consume CPU but its cheap and will hit performance of application.
Best Regards,
|
|
|
|
|
And queue objects with message and connection details?
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Did not get it
|
|
|
|
|
Thread.Sleep(50) is VERY WRONG synchronization.
In fact it's no syncrhonization at all, it just decrease bug frequency, making them even more difficult to debug.
Beside you only need 2 thread and a queue.
1 reader thread (or num CPU/2)
1 writer thread (or num CPU/2)
and then a queue of
{
Stream dest;
byte[] data
}
|
|
|
|
|
Just to be sure, you're reading from and writing to a dataStream variable. Are those two different data streams in two different classes or are they the same stream?
Logifusion[^]
|
|
|
|
|
yes dataStream is an object of NetworkStream which is used for both reading and writing messages on the stream. Any solution?
Best Regards
|
|
|
|
|
The situation you have matches what you would use a ReaderWriterLock[^] for. A reader/writer lock allows only one writer at a time, but several readers at a time.
The only concern I would have after that is if you can only allow one reader at a time. In that case, I would stick with the lock you have, but apply the lock to readers as well. In the code you have above, it looks like you obtain a lock to write to the stream, but not to read. If a call to the read method happens in the middle of your write method, there's nothing in that read method checking if there's a lock or not. So it's entirely possible reads are still happening during your writes. You have to use the lock on both sides.
Logifusion[^]
|
|
|
|