Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

xanburzum

caminho mais amigável

Recommended Posts

Com essa funçao voce exibe formatos de um caminho mais amigável para o usuário. FacPath é

úteis para aparar as longas diretório ou abreviar caminhos-los.

 

Nenhuma tentativa é feita por FacPath para determinar a validade do

caminho, ou se o caminho já existe no servidor.

 

sintaxe:

 

string = FacPath(sPath, hLen, bFile, bExtOnly)
exemplo:

 

<%
Dim testFldr

testFldr = "C:\Documents and Settings\Administrator\Desktop\Nova pasta\pasta\pasta\nome_do_arquivo.asp"

'resultado: C:\Docum...\Admin...\Deskt...\Nova p...\past...\past...\nome_do_arquivo.asp
Response.Write(FacPath(testFldr, 5, true, false) & "<BR><BR>")

'resultado: C:\Docu...\Admi...\Desk...\Nova ...\past...\past...\nome...asp
Response.Write(FacPath(testFldr, 4, false, true) & "<BR><BR>")

'resultado: C:\D...\A...\D...\N...\p...\p...\p...asp
Response.Write(FacPath(testFldr, 1, false, true) & "<BR><BR>")

'resultado: C:\...\...\...\...\...\...\...asp
Response.Write(FacPath(testFldr, 0, false, true) & "<BR><BR>")

'resultado: C:\Doc...\Adm...\Des...\Nov...\pas...\pas...\nom...
Response.Write(FacPath(testFldr, 3, false, false) & "<BR><BR>")

'resultado: C:\Do...\Ad...\De...\No...\pa...\pa...\nome_do_arquivo.asp
Response.Write(FacPath(testFldr, 2, true, false) & "<BR><BR>")

'resultado: C:\Doc...\Adm...\Des...\Nov...\pas...\pas...\nom...asp
Response.Write(FacPath(testFldr, null, null, null) & "<BR><BR>")

testFldr = "/pasta/pasta/nome_do_arquivo.asp"

'resultado: /pasta.../pasta.../nome_do_arquivo.asp
Response.Write(FacPath(testFldr, 5, true, false) & "<BR><BR>")

'resultado: /past.../past.../nome...asp
Response.Write(FacPath(testFldr, 4, false, true) & "<BR><BR>")

'resultado: /p.../p.../p...asp
Response.Write(FacPath(testFldr, 1, false, true) & "<BR><BR>")

'resultado: /.../.../...asp
Response.Write(FacPath(testFldr, 0, false, true) & "<BR><BR>")

'resultado: /pas.../pas.../nom...
Response.Write(FacPath(testFldr, 3, false, false) & "<BR><BR>")

'resultado: /pa.../pa.../nome_do_arquivo.asp
Response.Write(FacPath(testFldr, 2, true, false) & "<BR><BR>")

'resultado: /pas.../pas.../nom...asp
Response.Write(FacPath(testFldr, null, null, null) & "<BR><BR>")
%>

code:

 

<%
Private Function FacPath(byval sPath, byval hLen, byval bFile, byval bExtOnly)
	Dim elements, i, tmp, bLast, sElm, sDelim, chopsize
	Dim showfullfilename, showfileextension

	chopsize = hLen
	showfullfilename = bFile
	showfileextension = bExtOnly

	if isnull(chopsize) then chopsize = 3
	if isnull(showfullfilename) then showfullfilename = false
	if isnull(showfileextension) then showfileextension = true

	bLast = false
	sDelim = "\"
	if instr(sPath, sDelim) = 0 then sDelim = "/"
	elements = split(sPath, sDelim)

	for i = 0 to ubound(elements)
		sElm = elements(i)
		if len(sElm) > 5 then
			if i = ubound(elements) then 
				if showfullfilename then 
					tmp = ""
					exit for
				elseif showfileextension then
					tmp = right(sElm, len(sElm) - _
						instrrev(sElm, "."))
					bLast = true
				end if
			end if
			if chopsize > 0 then 
				elements(i) = left(sElm, chopsize) & "..." 
			else 
				elements(i) = "..."
			end if
			if showfileextension and bLast then 
				elements(i) = elements(i) & tmp
			end if
		end if
	next
	FacPath= Join(elements, sDelim)
End Function
%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

tambem não achei mais amigavel

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.