473,399 Members | 3,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

insert a unc path to db

How can I do the following in C# .NET:

In a directory somewhere on the network I have many .JPG or .PDF files. I
need a way to browse to that location on the network, select the directory or
the first file in that directory and then have the full UNC path of all the
files inserted into a SQL2k db, in a field named 'ThePath'

the unc filename should looks like this:

\\ServerName\DirectoryName\fileName.jpg or .pdf

Thanks

Paul
Jul 21 '05 #1
5 1545
First retireive it from the db using ExcecuteScalar - afterward you can just
use

DirectoryInfo di = new DirectoryInfo(ReturnValueFromDb);
foreach(FileInfo fi in di.GetFiles()){
}

--
W.G. Ryan MVP (Windows Embedded)

TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
<Pa******@newsgroup.nospam> wrote in message
news:F3**********************************@microsof t.com...
How can I do the following in C# .NET:

In a directory somewhere on the network I have many .JPG or .PDF files. I
need a way to browse to that location on the network, select the directory or the first file in that directory and then have the full UNC path of all the files inserted into a SQL2k db, in a field named 'ThePath'

the unc filename should looks like this:

\\ServerName\DirectoryName\fileName.jpg or .pdf

Thanks

Paul

Jul 21 '05 #2
I'm a little unclear about 'First retireive it from the db using
ExcecuteScalar'

There is nothing in the db yet, I first need to get the full path of where
the file names are and then insert that into the db.


"W.G. Ryan eMVP" wrote:
First retireive it from the db using ExcecuteScalar - afterward you can just
use

DirectoryInfo di = new DirectoryInfo(ReturnValueFromDb);
foreach(FileInfo fi in di.GetFiles()){
}

--
W.G. Ryan MVP (Windows Embedded)

TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
<Pa******@newsgroup.nospam> wrote in message
news:F3**********************************@microsof t.com...
How can I do the following in C# .NET:

In a directory somewhere on the network I have many .JPG or .PDF files. I
need a way to browse to that location on the network, select the directory

or
the first file in that directory and then have the full UNC path of all

the
files inserted into a SQL2k db, in a field named 'ThePath'

the unc filename should looks like this:

\\ServerName\DirectoryName\fileName.jpg or .pdf

Thanks

Paul


Jul 21 '05 #3
Hi Ryan,

Do you means you want to programly get a reference to a certain UNC shared
folder via its path and then enumerate all the files under that folder and
store all those files' fullpath into db?
If so, I think we can use the System.IO.DirectoryInfo class to get a UNC
folder's info (as long as that folder has shared with the appropriate
privilage).

For example:
the following code print out all the files's Full path under a give UNC
shared dir.

static void EnumUNCFolder(string uncpath)
{
DirectoryInfo di = new DirectoryInfo(uncpath);

if(di != null)
{
FileInfo[] files = di.GetFiles();

Console.WriteLine(di.FullName + " " + di.CreationTimeUtc);
for(int i=0;i<files.Length;i++)
{
Console.WriteLine("@ " + files[i].Name + " " + files[i].CreationTimeUtc);

}
}
}

we can use it like EnumUNCFolder(@"\\servername\shareddir")

HOpe helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 21 '05 #4
Yes, That's exactly what I meant.

Thank You
"Steven Cheng[MSFT]" wrote:
Hi Ryan,

Do you means you want to programly get a reference to a certain UNC shared
folder via its path and then enumerate all the files under that folder and
store all those files' fullpath into db?
If so, I think we can use the System.IO.DirectoryInfo class to get a UNC
folder's info (as long as that folder has shared with the appropriate
privilage).

For example:
the following code print out all the files's Full path under a give UNC
shared dir.

static void EnumUNCFolder(string uncpath)
{
DirectoryInfo di = new DirectoryInfo(uncpath);

if(di != null)
{
FileInfo[] files = di.GetFiles();

Console.WriteLine(di.FullName + " " + di.CreationTimeUtc);
for(int i=0;i<files.Length;i++)
{
Console.WriteLine("@ " + files[i].Name + " " + files[i].CreationTimeUtc);

}
}
}

we can use it like EnumUNCFolder(@"\\servername\shareddir")

HOpe helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 21 '05 #5
You're welcome.

Good Luck:)

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: rabbit | last post by:
Hi all, I want to know, how can i insert the xml data using createXML() with CLOB in the xmltype column? I store the xml data at first in the clob column und want to import these data in the...
2
by: Vissu | last post by:
Hi, I am trying to move bulk of data from one table to another (all in the db). Can I use direct insert method for doing this ?. I want to reduce my resource consumption (undo tablespaces,...
46
by: dunleav1 | last post by:
I have a process that does inserts that runs 50% slower that Oracle and Mssql. Queries normally take 50% slower than normal. DB2, Oracle, Mssql all are configured on same os, same disk array...
1
by: Tiago Vieira | last post by:
Hi everybody, I'm trying to insert a piece of javascript inside of a web service method but It's not working. Have somebody already tryed to do it? Folow a piece of my code below. ---------...
5
by: coolminded | last post by:
hi everyone i have a problem, i just export the data from data grid to the word file, but now the problem is i want to insert the picture in the word with the path name in the grid. for ex; i...
10
by: electric_r | last post by:
Hallo, I have 2 questions: with php and mysql : 1) How can I insert a text file into a TEXT field of a table ? 2) How can I insert a microsoft word file into a BLOB field of a table ?
10
by: Steve Kelley | last post by:
Hello all. I'm new to this group and I'm working on my first real VB.Net project. I'm having trouble creating and archive of a database. We use an Access database to store results from our...
1
by: accessvbanewbie | last post by:
I would like to export a recordset from access to excel but after each record is exported I want to insert a new row. The first recordset does this ok. However, the second recordset onwards does not...
3
by: wizardry | last post by:
hello - ive inserted user names, etc. into the longblob but the path to the image is giving me a bit of a trouble. do i need to change a mimi type or transformation of some sort? i've...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.