how to get file path using browse button in vb6 [duplicate] - vb6

This question already has answers here:
Find the directory part (minus the filename) of a full path in access 97
(9 answers)
How to extract directory from a file path string?
(4 answers)
Closed 4 years ago.
I am using this code, it gives the file name like "C:\File\sample.txt". But I am in need of getting path like "C:\File\". How can I get this path?
Private Sub cmdBrowse_Click()
CommonDialog1.ShowOpen
txtPath1.Text = CommonDialog1.FileName
End Sub

In FileName is Your dialog Box FileName that Contains Your File Name..You Need to Remove It By Finding Filename with a \
With CommonDialog1
TextBox1.Text = .FileName.Substring(0, .FileName.LastIndexOf("\"))
End With
This code Finds Last \ from your File Path ("C:\File\sample.txt").Basically File Path Has Filename at the end of File Path.So Find the Last \ and Remove it. this Is working Fine form me.

Try
txtPath1.Text = Mid(CommonDialog1.FileName, 1, InStrRev(CommonDialog1.FileName, "\"))

Related

How do I get the path without the last folder using ruby? [duplicate]

This question already has answers here:
Get parent directory of current directory in Ruby
(4 answers)
Closed 6 years ago.
Example given:
My path is (given by Dir.pwd) "D:/home/usr/documents/text files/2016"
What is a simple way to get the path without the last subfolder.
Result should be: "D:/home/usr/documents/text files"
Currently I do this
path = Dir.pwd.reverse.partition("/")[-1].reverse
Works, but I guess I miss the better way.
Thanks in advance!
File.expand_path("..", Dir.pwd)

FlashAir Execute on Write Event Properties

Using the dropbox sample code I am working on a Lua script that will run each time a new file is added (a photo in this case) to a specific folder. I see examples to iterate through a folders files to upload them each in turn. What I need is the properties that are passed to the file that will execute each time a new file is written. I'm hoping it will be passed the filename for the last file created so I can use that to upload the file directly to Dropbox or FTP site.
HI someone in japan solved your doubt as the following.
last_filepath = ""
max_mod = 0
fpath = "/DCIM/100__TSB"
for filename in lfs.dir(fpath) do
filepath = fpath .. "/" .. filename
mod = lfs.attributes( filepath, "modification" )
if mod > max_mod then
max_mod = mod
last_filepath = filepath
end
end
basically it set a directory to search for the latest file with newest modification date/time.
details r here
http://dotnsf.blog.jp/archives/1040120555.html

Find files in Visual Studio Solution with no code (e.g. blank or completely commented out) [duplicate]

This question already has answers here:
Find completely commented files
(4 answers)
Closed 9 years ago.
I was going through my solution and found a couple of classes that had been totally commented out. I'd like to remove these from my solution, and get the changes checked into source control. I assume someone over time has either re factored this code or removed whatever functionality it originally delivered.
I'm just wondering if there are any more class files in my project like this so I can get rid of the garbage.
Not aware of any such tool available in VS(not third party) but you can find "//" in whole project and manually select files mostly commented, otherwise write a tool(Console App) that scan all files in sub directories and return filenames if 80% of the lines starts with // in a file
Heres a VS macro which find files which start with /* or their length is 1 or less. Of couse you can improve this with "contains // public class" if statement and similiar ones.
Public Sub AllFilesWhichAreEmptyOrCommentedOut()
Dim solution As Solution = DTE.Solution
For Each prj As Project In solution.Projects
For Each file As ProjectItem In prj.ProjectItems
If file.Name.EndsWith(".cs") OrElse file.Name.EndsWith(".vb") Then
file.Open()
Dim selection As EnvDTE.TextSelection = file.Document.Selection
If selection Is Nothing Then
Continue For
End If
selection.StartOfDocument()
selection.EndOfDocument(True)
Dim content As String = selection.Text
If content.StartsWith("/*") Then
Log("File " & file.Name & " starts with /*")
End If
If content.Length <= 1 Then
Log("File " & file.Name & " is empty.")
End If
' Reset selection back to top
selection.StartOfDocument()
End If
Next
Next
End Sub
find . -type f -exec sh -c 'grep -vq "^//" {} || echo {}' \;
As answered here.

Bash - move a file to a specific path inside a zip file [duplicate]

This question already has answers here:
linux how to add a file to a specific folder within a zip file
(4 answers)
Closed 9 years ago.
I have a file that placed in the following directory:
folder/another_folder/file_to_add.xml
Now, what I want to do is simply add the file to a folder in the zip
For example this is my zip content:
my_zip.zip/folder/another_folder
How can I add the 'file_to_add.xml' to the 'another_folder'?
my_zip.zip/folder/another_folder/file_to_add.xml
Important!
I don't want to create folders with the same names and add them.
There is a command that allow me to do that?
Thanks
You can invoke python for this:
#!/bin/bash
python -c '
import zipfile as zf, sys
z=zf.ZipFile(sys.argv[1], "a")
z.write(sys.argv[2], sys.argv[3])
z.close()
' my_zip.zip your/existing/file_to_add.xml directory_in_zip/file_to_add.xml
This will open my_zip.zip and add your/existing/file_to_add.txt from the file system as directory_in_zip/file_to_add.xml in the zip file.

How do I specify a relative local file path in DOS? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How do I dynamically specify a file in DOS?
I am using c#.NET 2.0 to execute DOS commands to ftp a file. All works except for 1 thing, in the cmd file I call, it runs a PUT statement. Right now the put statement has a hardcoded local file path. I need to specify a dynamic path. I've tried
put %~dp0\myfile.DTL myfile.dtl
but it says it can't find the file.
Right now the .NET code calls a BAT file which only exist to call the CMD file. Interestingly, the BAT file DOES successfully use a relative path in its call to the CMD file:
ftp.exe -s:%~dp0\oit.cmd
However, I can't get that relative path to wrok in the cmd file:
open <my host>
<user name>
<password>
put <hardcoded path that needs to be relative path>localfilename remotefilename
I'll bever know where it will exist so I just need to grab whatever local directorey the file is in.
Relative is "." (dot).
Can you post the exact situation? What directory are you in, and where is the file?
Be careful with the "~" char ... it has a special meaning for DOS files (8.3 notation)
Use System.IO.Directory.GetCurrentDirectory() to get the current (working) folder.
Alternatively, if you want the path relative to your .EXE file, you can use System.Reflection.Assembly.GetEntryAssembly().CodeBase to get full path to your .EXE file, then use System.IO.Path.GetDirectoryName() to get the directory name of that path.
After that, you can use System.IO.Path.Combine to get absolute path out of relative:
string absPath = Path.Combine( #"c:\working\folder", #"sub\folder\file.ext" );
// absPath == "c:\working\folder\sub\folder\file.ext
// Works with double-dot too:
string absPath2 = Path.Combine( #"c:\working\folder", #"..\up\file.ext" );
// absPath == "c:\working\up\file.ext

Resources