|
I've done something similar in VBA once. Take a look into BuiltInDocumentProperties, maybe you'll finf what you need
<br />
Public Function GetWordTitle(strFileName As String) As String<br />
Dim wordApp As New Word.Application<br />
<br />
wordApp.Documents.Open strFileName, , True<br />
wordApp.Visible = False<br />
GetWordTitle = wordApp.ActiveDocument.BuiltInDocumentProperties("Title")<br />
<br />
<br />
wordApp.ActiveDocument.Close False<br />
Set wordApp = Nothing<br />
End Function<br />
|
|
|
|
|
Hi ALL
How can I read text file and make some process on it after it uploaded on the server.
Ala Qunaibi
Ala Qunaibi
|
|
|
|
|
That depends, is it your server ? Do you want to read it on the server, or on the client ? Once it's gone to the server, the client can only read it if you write methods on the server to send it back down again.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks Christian Graus
I want to read uploaded text file on my server.
How can i do that?
Ala Qunaibi
|
|
|
|
|
OK, then exactly as I said, it needs to exist in a way that can be browsed to, or it needs otherwise to be exposed by the web site.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hello everybuddy,
I am a little confused about why reading and writing a resource concurrently may be unsafe in some scenarios as I explain:
1. Blocking multiple threads from writing a resource based on its current value (such as incrementing some number, or manipulating some collections) is logical and I have no problem with it.
2. Blocking multiple threads from setting a resource to some new value independent of its current value seems unnecessary in my opinion, I need some clarification by some friend here why such synchronization is required. (more details: while there is no guarantee that if we block at start of the write process, which thread enters the section first, then that should not be important in not-locking scenario, which thread completes actual write instructions first and the other overwrites it, so why should we lock?! ).
3. Blocking two threads that one is writing the resource and another is reading it, also seems unnecessary, again I need clarification. (More details: Again we don't know which thread enters the locked section first, so that should not be important in not-locking scenario if the reader thread reads the value before the write process completely takes place or after that).
Thank you so much for any help
- den2fly
---
"Art happens when you least expect it."
|
|
|
|
|
For sure, there are situations where a single variable can be written and read by multiple
threads without needing a lock.
And there are some situations where a more complex set of data can be maintained without
a lock. Example: a circular buffer used by only one producer and only one consumer.
When you assemble such queue with a fixed-size array, a last-produced index and a
last-consumed index, it can work perfectly without any synchronization.
But then there are many situations where a group of values describe the state of something,
and not all combinations of values are allowed; so when a new state needs to be established
multiple values need updating, and reading some of them while that update is happening
would result in an unconsistent view. Here you definitely need locks.
Hope this helps.
Luc Pattyn
|
|
|
|
|
Thank you very much for the helpful info yo provided. But I still need dedicated replies on the three situations I explained in details.
---
"Art happens when you least expect it."
|
|
|
|
|
If you provide a code snippet where you are not sure a lock is required, I could help
you in showing it does or does not need a lock. For each method shown, please indicate
how many threads (1 or more?) could be executing it.
Luc Pattyn
|
|
|
|
|
Sample:
Here I have a collection class that I want to be thread safe for reading from and manipulation (Not also in the case of iterations). It is assumed any number of threads may enter any of the methods or indexers at the same time. I think for reading from indexers there is no need for a lock, even if there is a chance for more than one thread to enter the indexers, and/or at the same time to one of the Add, Remove, Clear methods. Is it correct? (sorry I don't know how to format code snippets in the post)
internal class MyThreadSafeCollection : System.Collections.Specialized.NameObjectCollectionBase
{
const int readLockTimeout = 100;
const int writeLockTImeout = 100;
private ReaderWriterLock rwLock = new ReaderWriterLock();
public MyThreadSafeCollection()
{
}
public object this[int index]
{
get
{
rwLock.AcquireReaderLock(readLockTimeout); // IS THIS REQUIRED ??
try
{
return BaseGet(index);
}
finally
{
rwLock.ReleaseReaderLock();
}
}
}
public SocketClientData this[string id]
{
get
{
rwLock.AcquireReaderLock(readLockTimeout); // IS THIS REQUIRED ??
try
{
return BaseGet(id);
}
finally
{
rwLock.ReleaseReaderLock();
}
}
}
public void Add(string id, SocketClientData client)
{
rwLock.AcquireWriterLock(writeLockTImeout); // I Know it is required. (isn't it?)
try
{
BaseAdd(id, client);
}
finally
{
rwLock.ReleaseWriterLock();
}
}
public void Remove(string id)
{
rwLock.AcquireWriterLock(writeLockTImeout); // I Know it is required. (isn't it?)
try
{
BaseRemove(id);
}
finally
{
rwLock.ReleaseWriterLock();
}
}
public void Clear()
{
rwLock.AcquireWriterLock(writeLockTImeout); // I Know it is required. (isn't it?)
try
{
BaseClear();
}
finally
{
rwLock.ReleaseWriterLock();
}
}
---
"Art happens when you least expect it."
|
|
|
|
|
OK, AFAIK the general answer is yes, you need all the locks:
1)
for operations that modify the data (add, remove, clear) if more than one thread were
to perform a modification at the same time, the result would be unpredictable without lock.
2)
for operations that just read the data, if another thread were to write at the same time,
the results again COULD be unpredictable (it depends on how the data actually is structured),
so you should acquire a reader lock (which is less demanding than a writer lock, it does not block other readers on the same object).
3)
of course there is an overall concern as to where the lock needs to be implemented.
My answer typically is at the highest possible level, i.e. the level where your
functional primitives are located. Example: if you use an indexor into a collection,
what is the meaning of the index if the collection could change in the mean time ?
void sumAll(myCollection) {
int sum=0;
int n=myCollection.Count;
for (int i=0; i<n; i++) sum=sum+myCollection[i];
return sum;
}
in the above snippet, seems to me the entire for loop needs a lock, otherwise how
can we be sure we get the collection items we intended, since without an overall lock
the collection (and hence the index-object relations) may change (probably not so
if lookup by key). In the example, the items summed may not be the ones that were in
the collection at the time the count was obtained !
Once you do use an overall lock, you may not want a low-level lock
anymore (and that is, I guess, why the NET Collections dont have a lock built-in).
So in conclusion:
- there has to be a lock on all operations
- positioning the lock code is a design issue:
too low ==> may produce wrong results
too high ==> may be counterproductive (multithreading not working anymore),
and possibly deadlocks
as for performance, locks at higher level are better (fewer acq/rel).
- All this makes it difficult, if not impossible, to build a really useful thread-safe
collection, independent of the application itself.
Hope this helps.
Luc Pattyn
|
|
|
|
|
Thank you very very much buddy, Yes that really helped and clarified a lot for me
I wish I can help u back some day.
---
"Art happens when you least expect it."
|
|
|
|
|
Hello every one. i have develope a chat software in C# and online help for it but i dont know the way how to access the main page of that online help from the help menu button. Is there any one who can help me in this regard??????
|
|
|
|
|
Process.Start will launch the doc with the default viewer. IE can be embedded in your app, if you prefer.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I've finshed my project but I could not run my program on other computer.
I tried update .NET framework 2.0 but it still not work.
How can I make sure my program will run on every PC (XP Sp2 + .NET 2.0)
|
|
|
|
|
If you've installed .NET 2.0, then you must be using another component that you need to install. What's the error - if you have .NET installed, it should run enough to tell you what it needs.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
What you are talking about is "deploying applications".
You find (almost) all you need here[^].
SkyWalker
|
|
|
|
|
Even when I use deploying, it is error. Pop up window shown "application error and need to close". That's all. It does not tell me anything.
|
|
|
|
|
Something must go wrong.
Try a debug version of your application on the computer where it doesn't work. You need to get more information on what's going on.
SkyWalker
|
|
|
|
|
I found out that I included some library which is not common amoung XP SP2.
After removed this outeverything work fine.
Thank you very much
|
|
|
|
|
Good
SkyWalker
|
|
|
|
|
Hi,
I have function that is in my class file (ojblib.c) this function is returning a single value based from my select statement. Could someone please help me on how to return 2 to 3 value at the same. Is dataset correct or is there any other way to return a value?
Name.Text = GetValue("Select username,tel,addres from employee where id=123");<br />
<br />
function string GetValue(string TxtSel)<br />
{<br />
string svalue="";<br />
objcon.Open()<br />
objcmd = new sqlcommand(TxtSel,objcon);<br />
svalue = objcmd.executescalar().ToString();<br />
objcon.close()<br />
return svalue.ToString();<br />
}
Thanks
/Dabuskol
Dabsukol
|
|
|
|
|
you can pass ref(ByRef in VB) parameters :
<br />
function string GetValue(string TxtSel,ref string Return1, ref string Return2)<br />
|
|
|
|
|
You can also use the out keyword. In contrast to the ref keyword, it doesn't require the so marked variable to be initialized before the method call.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Actually, the big difference is your function cannot return before assigning a value to an out parameter.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|