begin process at 2012 02 17 08:34:17
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Texte

 > POSITION D'UN FICHIER PAR RAPPORT À UN AUTRE DANS DES DOSSIER DIFFÉRENTS

POSITION D'UN FICHIER PAR RAPPORT À UN AUTRE DANS DES DOSSIER DIFFÉRENTS


 Information sur la source

Note :
7,5 / 10 - par 2 personnes
7,50 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Texte Niveau :Débutant Date de création :09/05/2002 Date de mise à jour :13/05/2002 15:44:04 Vu :1 772

Auteur : leptidev

Ecrire un message privé
Site perso
Commentaire sur cette source (3)
Ajouter un commentaire et/ou une note

 Description

Cette fonction retourne le nouveau chemin du fichier ficEnd par rapport au fichier ficInit qui se trouve dans un dossier différent ou même le même d'ailleur, par exemple :

getPathDos("C:\TOM\TOM\diane.txt", "C:\TOM\DIANE\TOM\tom.txt")

Vous retourne :

...\DIANE\TOM\tom.txt

Assez utilie parfois  

Source

  • Public Function getPathDos(FicInit As String, FicEnd As String) As String
  • Dim temp As String, tempFichier As String
  • Dim i As Long, o As Long
  • Dim tabInit() As String, tabEnd() As String
  • tempFichier = trouver_fichier(FicEnd)
  • FicInit = retourne_chemin(Right(FicInit, Len(FicInit) - 2))
  • FicEnd = retourne_chemin(Right(FicEnd, Len(FicEnd) - 2))
  • tabInit = Split(FicInit, "\")
  • tabEnd = Split(FicEnd, "\")
  • i = 0
  • Do Until tabInit(i) <> tabEnd(i)
  • i = i + 1
  • If i >= size(tabInit) Then Exit Do
  • If i >= size(tabEnd) Then Exit Do
  • Loop
  • For o = i To size(tabInit) - 1
  • temp = temp & "...\"
  • Next
  • For o = i To size(tabEnd) - 1
  • temp = temp & tabEnd(o) & "\"
  • Next
  • getPathDos = temp & tempFichier
  • End Function
Public Function getPathDos(FicInit As String, FicEnd As String) As String
Dim temp As String, tempFichier As String
Dim i As Long, o As Long
Dim tabInit() As String, tabEnd() As String
tempFichier = trouver_fichier(FicEnd)
FicInit = retourne_chemin(Right(FicInit, Len(FicInit) - 2))
FicEnd = retourne_chemin(Right(FicEnd, Len(FicEnd) - 2))
tabInit = Split(FicInit, "\")
tabEnd = Split(FicEnd, "\")
i = 0
Do Until tabInit(i) <> tabEnd(i)
i = i + 1
If i >= size(tabInit) Then Exit Do
If i >= size(tabEnd) Then Exit Do
Loop
For o = i To size(tabInit) - 1
temp = temp & "...\"
Next
For o = i To size(tabEnd) - 1
temp = temp & tabEnd(o) & "\"
Next
getPathDos = temp & tempFichier
End Function   

 Conclusion

Personne n'a remarqué que j'ai oublié les fonctions trouver_fichier et retourne_chemin, je rajouterai ces 2 fonctions ce weekend.


 Sources du même auteur

SAVOIR SI UNE FEUILLE EST CHARGÉ (CORRECTION)
Source avec Zip SIMULATION DE LA BARRE DE TITRE
DÉPLACER UN CONTROLE EN DRAGDROP
Source avec Zip EXPLOREUR LOCAL + SERVEUR
Source avec Zip EXPLOREUR SIMPLE ET RAPIDE (F.S.O.)

 Sources de la même categorie

Source avec Zip Source avec une capture MASQUE DE SAISIE NUMÉRIQUE par acive
Source avec Zip Source .NET (Dotnet) COMPTEUR DE NOMBRE DE MOTS DANS UN TEXTE par alpha5
Source avec Zip Source avec une capture HM - BLOCNOTE par hassenmajor
Source .NET (Dotnet) [VB.NET] CLASS DE COLORATION SYNTAXIQUE "ON THE FLY" par huzima
Source avec Zip Source avec une capture PERSONNALISEZ VOS BOÎTES DE MESSAGE (X)HTML par medjahedScript

Commentaires et avis

Commentaire de Stephane le 09/05/2002 21:09:12

salut

j'ai pas testé si ca marche mais en tout cas c'est tres pratique

merci
a+

Commentaire de Sylfurd le 10/05/2002 12:14:05

C vrai qu'il fallait y penser mais c vrai que le code peut etre plus optimisé!!
En out cas très bone idée! 7/10

Commentaire de neojoce le 10/05/2002 15:27:25

Je catch rien, trop pour mon intelligence lol, nice, continu !

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,780 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales