|
Make sure checkedFiles ends on a backslash, making it a folder, not a file.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
It has an ending backslash. The file is made with Path.Combine()
And in there i added the ending slash.
|
|
|
|
|
Please show us the first and last of the filePaths[] elements, and the checkedFiles value, as seen by your app.
Why do you use Directory.Move rather than File.Move ?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
I tried them both. And both give me the same error at runtime.
Here are the 2 elements in the filePaths[]:
[0]"C:\\Users\\The User\\Documents\\Visual Studio 2008\\Projects\\ProjectMultiThread\\ProjectMultiThread\\bin\\Debug\\filesToCheck\\634029044974663752.txt"
[505]"C:\\Users\\The User\\Documents\\Visual Studio 2008\\Projects\\ProjectMultiThread\\ProjectMultiThread\\bin\\Debug\\filesToCheck\\634029930615165770.txt"
The checkedFiles variable:
C:\Users\The User\Documents\Visual Studio 2008\Projects\ProjectMultiThread\ProjectMultiThread\bin\Debug\Checked Files\
I tried the 'checked files' with and without a space.
Just for the record, I'm trying to move this file from folder filesToCheck: '634029930615165770.txt'
To the 'Checked Files' folder.
I have used File.Move and:
FileInfo fi = new FileInfo(this.filesToCheck);modified on Monday, March 1, 2010 5:28 AM
|
|
|
|
|
Luc Pattyn,
I fixed the problem. I found this site:
http://www.devnewsgroups.net/dotnetframework/t1557-file-move-file-copy-exception.aspx[^]
And: Jacky Kwok's reply to someone else's post did the trick.
But I don't quite understood what he said. A quote from what I mean:
[quote]
The "BackUpPath" in both "Copy" and "Move" in your code are directory only.
However, the "File.Copy" and "File.Move" require it is filename.
[/quote]
If I understand this correctly, File.Move wants in both arguments a File name like this:
File.Move(file1, file2);
Isn't that odd? I'm trying to move a file from one directory to another. But here, you're moving a file to another file?
|
|
|
|
|
Yes, File.Move takes two filenames, that is perfectly clear in the documentation.
FYI: when both files reside in the same disk partition, the file data is not copied, the file is just renamed, i.e. one or two folder lists get modified.
The documentation on Directory.Move is not very clear however; AFAIK it can move an entire folder (when given two folder names), or it moves a single file (when given two file names).
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
So you're saying i have to pass the same file name to the destination argument too?
|
|
|
|
|
Hi Luc,
It seems that the files which are moved, are somehow messed up.
- If i try to open it, it's empty and ms windows is 'asking' me if i want to create a new file.
- If i try to delete the file, windows is 'telling' me that the file "is no longer located in the-file-path".
I was hoping you could help me out here.
|
|
|
|
|
hello everybody,
i need to wrap a Queue so multiple threads will be able to add/get messages from it. if the queue is empty - the thread will wait until it has data.
it works for a couple of seconds and then throws an exceptions that my Queue is empty. why is that?
thanks,
public class SyncQueue<T>
{
private Queue<T> queue;
private object readerLock;
private object queueLock;
private AutoResetEvent dataAvailable;
public SyncQueue()
{
this.queue = new Queue<T>();
this.readerLock = new object();
this.queueLock = new object();
this.dataAvailable = new AutoResetEvent(false);
}
public void Enqueue(T item)
{
lock (queueLock)
{
queue.Enqueue(item);
}
dataAvailable.Set();
}
public T Dequeue()
{
lock (readerLock)
{
if (queue.Count == 0)
{
dataAvailable.WaitOne();
}
lock (queueLock)
{
return queue.Dequeue();
}
}
}
} modified on Sunday, February 28, 2010 4:40 PM
|
|
|
|
|
I can't reproduce problem. I used 8 threads and try it also as static.
|
|
|
|
|
 input is: 1,2,3,4,5,6,7,8,9,10 (several times)
namespace Test
{
public class SyncQueue<T>
{
private Queue<T> queue;
private object readerLock;
private object queueLock;
private AutoResetEvent dataAvailable;
public SyncQueue()
{
this.queue = new Queue<T>();
this.readerLock = new object();
this.queueLock = new object();
this.dataAvailable = new AutoResetEvent(false);
}
public void Enqueue(T item)
{
lock (queueLock)
{
queue.Enqueue(item);
Console.WriteLine("Enqueued Item: " + item);
}
dataAvailable.Set();
}
public T Dequeue()
{
lock (readerLock)
{
if (queue.Count == 0)
{
dataAvailable.WaitOne();
}
lock (queueLock)
{
return queue.Dequeue();
}
}
}
}
public class Tester
{
SyncQueue<int> myQ = null;
public Tester(SyncQueue<int> queue)
{
myQ = queue;
}
public void ProcessMessages(object obj)
{
while (true)
{
Console.WriteLine(myQ.Dequeue());
}
}
}
public class Program
{
static void Main(string[] args)
{
SyncQueue<int> myQ = new SyncQueue<int>();
Tester t1 = new Tester(myQ);
Tester t2 = new Tester(myQ);
Tester t3 = new Tester(myQ);
ThreadPool.QueueUserWorkItem(new WaitCallback(t1.ProcessMessages));
ThreadPool.QueueUserWorkItem(new WaitCallback(t2.ProcessMessages));
ThreadPool.QueueUserWorkItem(new WaitCallback(t3.ProcessMessages));
while (true)
{
string[] snumbs = Console.ReadLine().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string snumb in snumbs)
{
myQ.Enqueue(int.Parse(snumb));
}
}
}
}
}
the exception is: Invalid Operation Exception - queue is empty.
any idea?
thanks,
|
|
|
|
|
It was pretty easy to debug when you posted actual test code. The problem lies within AutoResetEvent. WaitOne will not wait till its state isn't resetet. add this:
dataAvailable.Reset()
dataAvailable.WaitOne();
|
|
|
|
|
ok thanks,
but isn't autoResetEvent supposed to change it's own state automatically after WaitOne()?
i thought that's what it is doing...
maybe i don't understand the difference between auto and manual reset events. can anyone explain?
thanks again.
|
|
|
|
|
|
yeah you're right! something is missed up...
that's what made me be confused about my code at first place...
weird.... thank anyway though!
|
|
|
|
|
please help me I want to print saerch results,if I can send them to microsoft report it's better and if I could print it or save it in pdf format it would be good for my work.if one of them is possible please tell me!
|
|
|
|
|
both of them are possible.
For pdf ITextSharp
For ms reports(Crystal I assume) I can't help you => never used them.
But Ging(Google+Bing == Ging) could help 
|
|
|
|
|
thank you for your answer I will test it and tell you about it . but why I have to forget?
|
|
|
|
|
Ive been building an application that reveals information on what image files have been accessed by any given user
RegistryKey OurKey2 = Registry.Users;
OurKey2 = OurKey2.OpenSubKey(userID + "\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\OpenSavePidlMRU\\" + valuename);
foreach (string valuename2 in OurKey2.GetValueNames())
{
DataGridViewRowCollection rows = this.dataGridView3.Rows;
System.Byte[] strByte = (System.Byte[])OurKey2.GetValue(valuename2);
System.Text.Encoding enc = System.Text.Encoding.Unicode;
string myString = enc.GetString(strByte);
rows.Add(myString, valuename);
}
This gives me "䐟ᩇ夃㽲䒧얉镕毾" etc all gibberish
The actual value viewed in the registry doesnt exactly make sense but you can still read it
Can anyone tell me how to either just read a sensible value from it or how to find out what encrypt/encoding the registry uses on these values?
It also seems to only be reading the first part of the value
Thanks in advance Carl
|
|
|
|
|
I don't know what the content of these items are on your system, but on mine they appear to contain complex structures. Thus you cannot just read them as a byte array and convert to Unicode. You need to understand the structure of these keys and convert them according to the different parts of their structures. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
The competition[^] does not really know, but CodeProject[^] seems to know (yes, it is in C++).
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
modified on Sunday, February 28, 2010 5:49 PM
|
|
|
|
|
|
Hi,
How can I make a safe cross thread call for a textbox to set the 'text' of the textbox?
|
|
|
|
|
Use the InvokeRequired and if required Invoke() it. Else normal assignement.
|
|
|
|
|
Hi,
Do you got a sample for me?
Thanks in advance!
|
|
|
|