|
i modify my code. now send
object missingp = false; ref missingp instead of harcode code false but still no luck. can u guide me please. thanks
tbhattacharjee
|
|
|
|
|
The problem with many of these MSWord methods is that they have many parameters and it not easy to know which combinations are valid. I would suggest simplifying the HitHighlight method call and just specify the text to find, as that is the only required parameter. Set all others to Type.Missing. If that works as expected then reintroduce the other parameters, possibly one at a time.
There are warnings in the documentation that some parameters "may not be available", e.g. HanjaPhoneticHangul is available only if you have support for Korean languages. This may mean that it must be set to Type.Missing and not true or false. The documentation is not clear about this.
http://msdn.microsoft.com/en-us/library/office/bb226067(v=office.12).aspx[^]
http://msdn.microsoft.com/en-jm/library/microsoft.office.interop.word.find.hithighlight.aspx[^]
Alan.
|
|
|
|
|
In a C# 2008 windows application, I planning on locating files that I need to find by utilizing the following code:
var RFiles = from path in Directory.EnumerateFiles(filesaveLocation, "*.*",
SearchOption.AllDirectories)
let extension = Path.GetExtension(path)
where extension == ".pdf" || extension == ".xlsx" || extension == ".xls"
select path;
However once I find each selected file, I need to know the exact location of where each specified file was located. I need to be able to store the exact directory structure location in a sql server 2008 r2 database.
Basically the code statement would be similar to tell me exactly where each seelcted file is located at.
Thus can you me in code and/or explain to me how to accomplish my goal?
|
|
|
|
|
Have you checked the properties of that Directory object for anything useful, like the directory path it's representing??
|
|
|
|
|
In this case, you can switch to use the DirectoryInfo class to do this:
DirectoryInfo filesaveDir = new DirectoryInfo(filesaveLocation);
var RFiles = from fi in filesaveDir.EnumerateFiles("*.*", SearchOption.AllDirectories)
let extension = fi.Extension
where extension == ".pdf" || extension == ".xlsx" || extension == ".xls"
select fi.FullName;
|
|
|
|
|
How to use corrupted sql server database into oracle using c#
|
|
|
|
|
why do you want to move a corrupt database into Oracle? surely you should fix the SQL Database first
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
|
Add the .MDF file as a BLOB.
|
|
|
|
|
Dear All,
I am using Gridfs to store all my images in mongodb. How do i retrieve the images from mongodb using Gridfs. And with which C# control i can display the mondodb images. Please sugget any ideas.
|
|
|
|
|
ArunRajendran1 wrote: I am using Gridfs to store all my images in mongodb. How do i retrieve the images from mongodb using Gridfs.
You'd need to go through the GridFS documentation; it's not a generic C# subject, and most members will not recognize it. FWIW, there's an example on SO[^].
ArunRajendran1 wrote: And with which C# control i can display the mondodb images.
I'd suggest either a Panel or a PictureBox .
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
How to insert data using combo box in c# base language in windows base application ???
|
|
|
|
|
|
Hello,
I recently finished a C# course and I'm ready to create what could be a complex program, to me at least. The idea I have is to monitor a cad application that runs on the users machine and work on a design file locally but save it to the server every x number of minutes.
Users currently work on the files on a blade server that backups are mediocre at best, a network running at 100 and not gigabit.
After reading a few articles here on C# threads and processes I now have a few questions.
Can C# monitor when the application starts\ends via the task manager and get the file path and name so I can then do a time\date compare with the version on the server vs. the one on the local machine?
Anything to consider C# wise if a second instance of the application is started? They would be two different drawings and the task manager does show two applications and processes running.
Can this be set as a service to launch, or what would be the best way to implement this once a user logs on to the machine to catch the start of the application?
Should the FileSystemWatcher or EventHandler reduce the complexity?
Any input or guides to an example already existing is appreciated.
Or should I just stay with the "Hello World" example in the book?
Thanks!
I'll tell you what, then. Why don't you call me some time when you have no class? - Thornton Melon
|
|
|
|
|
You should always move beyond the "Hello World"!
<sig notetoself="think of a better signature">
<first>Jim
<last willyoudomyhomeworkforme="false">Meadors
|
|
|
|
|
You can try System.Diagnostics.Process.GetProcessesByName to get a list of Processes. But I do not know an event for a Process being started (perhaps WMI could do so), I'd poll the list every few seconds.
But more important: how much interoperation does the application to be montired allow? Can you query its current file? Is the file read-able when it is opened in that application (could be locked!)?
|
|
|
|
|
The software does save changes automatically in the drawing which would be local in this case and then I would have it save the drawing to the server every 20 minutes.
I did find a msdn topic on services http://msdn.microsoft.com/en-us/library/zt39148a(v=vs.80).aspx[^]
I think I may be on to something and I am testing it out.
The reading of articles and implementing this is a bit like herding cats at the moment.
I'll tell you what, then. Why don't you call me some time when you have no class? - Thornton Melon
|
|
|
|
|
Steps
- Learn how to create a windows service
- Learn how to use Process
- Figure out how to manage files and specifically detect time changes and how to copy.
- Figure out how the cad app 'saves' a file
Last step is more experimental. You should probably save two back ups and alternate as that gives a better chance of one not be bad due to a copy during a write.
Last step also involves figuring out where the file is saved and to which user it belongs.
mphill4744 wrote: Users currently work on the files on a blade server
This of course is all dependent on the presumption that the 'server' is in fact windows.
|
|
|
|
|
In a C# 2008 desktop application I would like to know how to change the following code so that the files I am looking for can be located.
string Format_Date = DateTime.Now.AddMonths(-1).ToString("MM-yyyy");
String filesaveLocation = null;
filesaveLocation = Path.Combine(ConfigurationSettings.AppSettings["tLocation"], Format_Date);
if (!Directory.Exists(filesaveLocation))
{
System.IO.Directory.CreateDirectory(filesaveLocation);
logging.Error("The location " + filesaveLocation + " does not exist.");
return packageId;
}
else
{
string[] RFiles = (from path in Directory.GetFiles(filesaveLocation)
let name = Path.GetFileName(path)
where name.EndsWith(".pdf") ||
name.EndsWith(".xlsx") ||
name.EndsWith(".xls")
select path).ToArray();
}
foreach (String RFile in RFiles)
{
}
The code was written for a directory path that looks like the following:
C:\Trans\01-2013 -Note the 01-2013 is for month and year.
Now I am finding out that the file directory stucture in production looks like the following:
R:\Trans\_JAN_2013\A-Sample. Under the A-Sample directory there are 4 separate subdirectories
called: SUB1, SUB2, SUB3, and SUB4.
I was expecting to see the files in one directory instead of 4 separate directories.
Thus can you show me code and/or tell me how you would change the code to accomodae the change in the file directory strucutre?
|
|
|
|
|
First to fix the Format_Date for the month as abbreviated name:
string Format_Date = DateTime.Now.AddMonths(-1).ToString("_MMM_yyyy");
Next, to get all of the file information from all subdirectories, change the code to build RFiles to be:
var RFiles = from path in Directory.EnumerateFiles(filesaveLocation, "*.*", SearchOption.AllDirectories)
let extension = Path.GetExtension(path)
where extension == ".pdf" || extension == ".xlsx" || extension == ".xls"
select path;
It probably isn't necessary to make this into an array if you are just going to iterate over the collection in a foreach . This Linq query will return an IEnumerable<string> which can be used directly in the foreach (unless you will be modifying the values in the collection during the loop).
The string comparisons in the query will be case-sensitive, just like your use of .EndsWith(...) .
Now, if all you are going to do is iterate over this collection of filepaths, why not skip building RFiles altogether:
foreach (string RFile in Directory.EnumerateFiles(filesaveLocation, "*.*", SearchOption.AllDirectories))
{
string extension = Path.GetExtension(RFile);
if (extension == ".pdf" || extension == ".xlsx" || extension == ".xls")
{
}
}
|
|
|
|
|
I like youtr idea of 'if all you are going to do is iterate over this collection of filepaths, why not skip building RFiles altogether:'.
However I need to write out error messages to a log file if 'specified' files are not located.
|
|
|
|
|
But any 'specified' files that are not located, by definition, will not be in the iteration, so (without seeing what you are doing with the file-paths) I still don't see why you would need the collection.
|
|
|
|
|
Hi,
you can set the "ConfigurationSettings.AppSettings["tLocation"]" somewhere in your code or settings to pick up the root directory. The get all the sub directories using DirectoryInfo, and for each directory in directiories check for files.
In addition the ConfigurationSettings.AppSettings property is obsolete from .Net 2.0 framework, you should not be using that property. Instead you should be using ConfigurationManager.AppSettings.
http://msdn.microsoft.com/en-us/library/system.configuration.configurationsettings.appsettings.aspx[^]
Regards
Jegan
Think! Don't write a line of code unless you absolutely need to.
|
|
|
|
|
Can you tell me when the ConfigurationSettings.AppSettings will no longer be supported in visual studio? I would like to know so that I can make the appropriate changes to use the ConfigurationManager.AppSettings settings instead?
|
|
|
|
|
It is obsolete since .Net 2.0 that is since VS2005.
Please see the link on my last message.
Jegan
Think! Don't write a line of code unless you absolutely need to.
|
|
|
|