Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Long file names to short filenames!

Posted on 2004-04-22
5
373 Views
Last Modified: 2010-04-24
1st
I need my application to find out directory where its in and show it in short filename. So far i got

        Dim caption As String
        caption = (Windows.Forms.Application.ExecutablePath)
        MsgBox(caption)

and it showing me something like this

D:\Visual Studio Projects\ex

but i want it to be

D:\visual~1\ex

how can i make it work????

2nd.

How to make my application to be on top of startbar???

0
Comment
Question by:g00r00
  • 3
  • 2
5 Comments
 
LVL 50

Accepted Solution

by:
Ryan Chong earned 20 total points
ID: 10896597
Try:

Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Integer) As Integer

Private Function FilePathToShort(ByVal OriginalFileName As String) As String
        'create a buffer
        Dim Buffer As String = Space(255)
        'copy the current directory to the buffer and append 'myfile.ext'
        Dim Ret As Integer = GetShortPathName(OriginalFileName, Buffer, 164)
        'remove the unnecessary chr$(0)'s
        Return Buffer.Substring(0, Ret)
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        MessageBox.Show(FilePathToShort("D:\Visual Studio Projects\ex"))
    End Sub
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 10896604
>>How to make my application to be on top of startbar???
Try:
Me.TopMost = True
0
 

Author Comment

by:g00r00
ID: 10900355
if you use me.topmost then your application will be ontop of all other applications, but not on top of the startbar,,,
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 10900623
>>but not on top of the startbar
Yes if the application window is Maximized, No if it's in Normal WindowState
0
 

Author Comment

by:g00r00
ID: 10902575
I try and even in maximized state its not of top of startbar, gime me the source code and i'll try it!!!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question