|
Hi,
I'm trying to delete folders with vb.net. I'm using the following code :
Directory.Delete(dir, True)
Problem : If there is readonly file, the function return an exception. Is there a way to bypass this ? Or should I browse each file and change the attributes before deleting them ?
Thx
|
|
|
|
|
Your best bet is to recurse through the folders:
<br />
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click<br />
<br />
Dim path As String = "C:\Test"<br />
<br />
RemoveReadOnly(path)<br />
<br />
IO.Directory.Delete(path, True)<br />
<br />
End Sub<br />
<br />
<br />
Private Sub RemoveReadOnly(ByVal path As String)<br />
<br />
Try<br />
<br />
Dim currentDir As New IO.DirectoryInfo(path)<br />
currentDir.Attributes = IO.FileAttributes.Normal<br />
<br />
For Each file As IO.FileSystemInfo In currentDir.GetFileSystemInfos()<br />
file.Attributes = IO.FileAttributes.Normal<br />
Next<br />
<br />
For Each directory As IO.DirectoryInfo In currentDir.GetDirectories()<br />
RemoveReadOnly(directory.FullName)<br />
Next<br />
<br />
Catch ex As Exception<br />
<br />
Console.WriteLine(ex.Message)<br />
<br />
End Try<br />
<br />
End Sub<br />
although you could cheat and use the command prompt:
<br />
Dim path As String = "C:\Temp"<br />
Dim command As String = Environment.GetFolderPath(Environment.SpecialFolder.System) & "\cmd.exe "<br />
Process.Start(command, " /C " & "rmdir /S /Q" & path)<br />
... not so professional looking though, but it depends on what your app is for.
Hope this helps
Tom
|
|
|
|
|
Thx for your help.
I'll use the command prompt solution. It's the faster for me.
Sybux
|
|
|
|
|
I am not able to create a record set through a dll. I am using the
db as database
rs as recordset method
and the opening database as db.opendatabase(sdfsdf,sdf)
into rs. It is not working through a dll,
I need it for a project. If anybody is willing to help mail me at
ruturajmd@yahoo.co.in or ruturajmd@gmail.com I shall send you the code for ur review
Please Help Me as soon as possible
|
|
|
|
|
You haven't really given us any details about what you're doing, what your requirements are, what your code looks like, ... All we have is some very vague ideas the you declared "db as database", which is meaningless by the way, "rs as recordset", ... We're going to need much more information in order to tell you anything usefull.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am sending you the basic requirement. What my project wants to do. I have to give it before 6th dec. Please help me it you can. It is a challenging project. I am not able to work on it due to lack of experience is file handeling field.
tInnovative Search and Indexing Techniques.
Locating the right document on computers is becoming increasingly difficult. While searches based on contents of certain types of documents (like Word, EXCEL, Powerpoint files) are available, it is not available for all types of documents such as pictures, music, and video files. This project speeds up document search by building and using indexes.
Various indexing and search techniques were studied and implemented in software, which periodically classify and index the documents on the user’s computer. The keywords identified in the documents are stored in the form of a database to be used for intelligent search. The index database facilitates faster search and allows the user to search for documents based on relevant terms rather than names of files and folders.
The software is developed using client server architecture, which allows search for information on other computers in the network. By enhancing the client and server component, the same can be extended to a web-based search for information
A specialized indexing technique was used for music files. By extracting 20 seconds of audio clips from the music files in WAV format, an index database was built. This database facilitates choosing the right music file based on the audio clips.
To understand content-based search of music, we attempted use of signal processing techniques to analyze music waveform patterns. Application of these techniques to match user-recoded clip with existing waveform was studied. The results are presented as future work needed to make voice based music search possible.
First of all, we're not doing your class work for you. Second, you haven't given any code sample where your having a problem. Just giving us the requirements is not enough.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Sir it is not a school project. I had sent this as a concept to a National level Science Convention Sponsered by Intel. The next level to it is the ISEF USA.
Please inform where to send the code.
Is it possible to extract Keyword, relevant word from doc asn text files. I havent been able to write such a program and that is where I am stuck up.
Thanks for replying. I am obliged to receive help from somebody
Thank you.
|
|
|
|
|
I'm not writing it for you. I barely have enough time to look at my own code, let alone someone elses.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hey,
I have a full file path e.g.
C:\Test\File.doc
Obviously this is a MS Word document. But is there a way from this file name to get the Application that is used, in this case winword.exe?
Thanks for your help, this is very urgent
chris
|
|
|
|
|
|
Cheers tom
a dream it does indeed
Take care
Chris
|
|
|
|
|
Hi,
I was able to write a piece of code that would hook a process and if I try to open a *.txt file, for example, a message would be displayed and the application, Notepad, would wait until I respond to the message. Now I would like to do the same thing remotely. For example..
1, Enable the hook on a server.
2, Access a network share on that server from my desktop
3, Open a file on that share and have a message displayed on the server side while at the same time making Notepad on my desktop wait until I respond to the message on the server.
A good example of this is in an HSM tool. No software is installed on the desktops but the applications wait for the recall to be complete before giving back control to the user.
Any help would be greatly appreciated.
Thanks,
|
|
|
|
|
Hi,
Does any one know a way in .Net to read and write at the disk block level?
Thanks
|
|
|
|
|
It cannot be done using the .NET Base Class Library. You'll have to P/Invoke the API calls yourself. You need to start with CreateFile[^]. There is alot to read and you MUST understand how to use these functions and structures completely. There is no example in VB.NET, this is all low level stuff best handled by C++.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Whenever i try to install assembly throug gacutil /i it shows Unkown Option: and help me out. Tell me how to install through gacutil
|
|
|
|
|
GacUtil checks each argument to see if it is a valid switch. If an invalid switch is found you get the "Unknown Option" error.
The most likely cause of this error is specifying an assembly (possible including the path) where there is a space in the name( or path).
The solution is to use quotes around the file name.
Eg.
GacUtil /i c:\My Dlls\MyDll.dll - Will error.
GacUtil /i "c:\My Dlls\MyDll.dll" - Will register fine.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
|
|
|
|
|
Dear All,
I really need help.
Does anybody know how to hide Treeview node in VB.net ?
Thank you very much for any helps and ideas.
Regards.
Edit/Delete Message
|
|
|
|
|
You can't. The control that the TreeView class wraps doesn't support it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to position a button programmatically, and I found a section of code. Is this the only way to do it?
' Visual Basic
Button1.Location = New Point(100, 100)
// C#
button1.Location = new Point(100, 100);
Thanks
Brendan
|
|
|
|
|
if u want to put it in any point ,
Yeah that is the only way really.
but u can dock it like
Button1.Dock = DockStylr.'as u like .
button1.Dock = DockStyle.// asu like also
or if u want to keep the diffrence between it and another Control u might use the Anchor property
ByMindOnlyYouCanDoIt
|
|
|
|
|
How do I open an URL using .NET? In Visual Basic 6 I used the ShellExecute API call. I defined the constant variables in a module file like this:
' Constant variables for the ShellExecute API
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_SHOW = 5
Public Const SW_MINIMIZE = 6
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_RESTORE = 9
Public Const SW_SHOWDEFAULT = 10
If this is the API to be used in .NET, where do I declare these constant variables? If there is another way of doing it, please let me know.
Thanks
Brendan
|
|
|
|
|
In the future, search the forums first. You answer has been covered so many times, it's silly. For instance, the same question was posted about 8 down from yours.
You need to use the Process class and just launch the URL. This will launch the default web browser with the URL you give it.
Process.Start("http://myurl.somehwere.com")
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I need help with regards to my frmSplash form. Not sure where to load it. I want it to display while the application loads. Where do I put the call to the frmSplash form? And how does a person determine how long an application loads? The name of my main/startup form is frmMain. Will this differ between VB.net and C#.net? I went through some Visual Basic 6 code and they did it in a module file like this:
Sub Main()
frmSplash.Show
End Sub
Thanks
Brendan
|
|
|
|
|
Why dont you put the form in a ascx file, set it in a Sub Control_load function.
file.ascx
<%@ Control Language="VB" Src="file.vb" Inherits="Classname">
<td
<asp:textbox="" id="Namefield" runat="server"> |
file.vb
Public Sub Control_Load(ByVal Sender As Object, ByVal E As EventArgs)
'The code in here will execute when loading a ascx file
End Sub
file.aspx
<%@ Register TagPrefix="UsrCtrl" TagName="FormSplash" Src="file.ascx" %>
'Point to it from your aspx code.
<usrctrl:formsplash id="Form" runat="server">
etc, etc
|
|
|
|
|
It's not a website, but an application.
|
|
|
|