رفتن به مطلب
  • 0

کار با فایل های کارت اس دی


amir00700

سوال

چطور میشه ادرس پوشه ای رو توی کارت اس دی داد

مثلا بیایم پوشه dcimرو بدیم و بگیم عکسهای داخلش رو لود کنه به صورت مولتی پنل

چیکار باید کنم؟

ممنون میشم کمک کنید

لینک ارسال
به اشتراک گذاری در سایت های دیگر

5 پاسخ به این سوال تاکنون داده شده است

ارسال‌های توصیه شده

منظور شما DirInternal هست ؟

اره

 

حالا موقع استفاده اینجوری بنویسید:

 

Dim path As String=GetExtRoot
    If path="" Then
        Try
            path=File.DirRootExternal
        Catch
            path=File.DirInternal
        End Try
    End If

 

من از این چیزی سر در نیاوردم و اگه میشه مبتدی تر توضیحش بدین

لینک ارسال
به اشتراک گذاری در سایت های دیگر

سلام.

شما باید اول لیست فایل های یه مسیر رو بگیرید:

Dim files As List
files.Initialize
files=File.ListFiles(File.DirRootExternal&"/Pooshe")

این مثلا فایل های پوشه Pooshe در حافظه رو میده ، بعد باید حالا با حلقه فور اینارو تشخیص بدید که کدومشون با فرمت عکس هستن جداشون کنید بریزید داخل یه لیست.

بعد از اون لیست با اسمشون فراخوانی کنید داخل مولتی پنل. :crazy:

لینک ارسال
به اشتراک گذاری در سایت های دیگر

سلام.

شما باید اول لیست فایل های یه مسیر رو بگیرید:

Dim files As List
files.Initialize
files=File.ListFiles(File.DirRootExternal&"/Pooshe")

این مثلا فایل های پوشه Pooshe در حافظه رو میده ، بعد باید حالا با حلقه فور اینارو تشخیص بدید که کدومشون با فرمت عکس هستن جداشون کنید بریزید داخل یه لیست.

بعد از اون لیست با اسمشون فراخوانی کنید داخل مولتی پنل. :crazy:

حافظه دو تا هستش

حافظه اس دی کارت

و خود گوشی

برای خود گوشی چطوره؟

لینک ارسال
به اشتراک گذاری در سایت های دیگر

برای خود گوشی چطوره؟

منظور شما DirInternal هست ؟

لینک ارسال
به اشتراک گذاری در سایت های دیگر

دستور file.dirrootexternal برای بدست آوردن آدرس حافظه خارجی است ولی اگه اشتباه نکنم روی گوشی های روت شده جواب میده و برای روت نشده ها آدرس شاخه روت حافظه داخلی رو برمیگردونه

یه تابع پیدا کردم که آدرس حافظه خارجی رو میده (امیدوارم)

Sub GetExtRoot As String
'Attempts to get and return the external root directory.
	Dim Rslt As Boolean 'Result of each location determination attempt.  See code.
	Dim I As Int 'Loop counter
	Dim TempRoot, StartDir, TestDir1, TestDir2, T1, T2 As String 'Holds temporary directories.
	Dim SB As StringBuilder 'Used to build the string that will hold the actual external SD card root directory.
	Dim SlashCnt As Int 'Holds the count of the "/" in processing TempRoot.
	'Initialize local variables.
	TempRoot = "Root not found."
	SlashCnt = 0
	SB.Initialize
	'Test the directories to determine whether or not DirRootExternal is the REAL external SD card..
	'The tests performed below are those for external SD card paths for an HTC Evo 4g and a Samsung Galaxy Proclaim, a Samsung Galaxy Note II and a Samsung Galaxy Note 10.1.  Had no devices by other manufacturers.
	
	'See the above line and the corresponding log line in the IDE.
	TestDir1 = File.DirRootExternal

	'I've used the Android subdirectory as the test because without using a subdirectory, the tests I made indicated that an SD card path that was correctly returned by DirRootExternal would not reveal that a card was not present when only the root was used in the test.  I believe we want to know a minimum of two things; what is the root path and whether or not a card is present or accessible (for example on some devices, a device connected to a PC in USB storage/disk drive mode is present but cannot be detected as present because it is inaccessible.  At least that is what the tests I've run show.  I really do wish we could use the Environment method/functions so that we could better know what exactly is the state of the media and be able to use that info to advantage in our apps.
	'Log("Test dir path:  '/mnt/extSdCard/Android'.")
	Rslt = File.IsDirectory("/mnt/extSdCard", "Android")
	If Rslt = True Then
		'Log("Directory 'Android' found on External SD Card.")
		TestDir2 = "/mnt/extSdCard/Android"
	Else
		'Log("Directory 'Android' NOT found on External SD Card.")
		'Log("New Test dir path:   '/storage/extSdCard/Android'.")
		Rslt = File.IsDirectory("/storage/extSdCard", "Android")
		If Rslt = True Then
			'Log("Directory 'Android' found on External SD Card.")
			TestDir2 = "/storage/extSdCardAndroid"
		Else
			'Log("Directory 'Android' NOT found on External SD Card.")
			'Log("New Test dir path:   '/mnt/sdcard/Android'.")
			Rslt = File.IsDirectory("/mnt/sdcard", "Android")
			If Rslt = True Then
				'Log("Directory 'Android' found on External SD Card.")
				TestDir2 = "/mnt/sdcard/Android"
			Else
				'Log("Directory 'Android' NOT found on External SD Card.")
				'Log("New Test dir path:   '/storage/sdcard/Android'.")
				Rslt = File.IsDirectory("/storage/sdcard", "Android")
				If Rslt = True Then
					'Log("Directory 'Android' found on External SD Card.")
					TestDir2 = "/storage/sdcard/Android"
				Else
				'This is the final option result.  If, using the above possibilities, the actual external SD card root directory hasn't been found, then either it is the same as the result of File.DirRootExternal or an external SD card is not present or not accessible.  Again, remember that manufacturers such as Motorola and Nokia may employ other names -- makes a required convention almost necessary if developers are to efficiently produce for all Android devices.  It is not like we are developing for a single, related family of devices by a single manufacturer (i.e. Apple).  By failing to require a standard approach, Google is limiting our market.
					'Log("Directory 'Android' NOT found on External SD Card.")
					'Log("All options have been tried.  External SD card is a) not present, b) is locked or c) is not available on this device.")
					'Msgbox("External SD Card cannot be found.  It is either not present, locked or a different name is used than that in this app.  If the latter appears to be the problem, please notify the publisher.  Otherwise, please insert an SD card and try starting the app again.  Because this app requires a user supplied SD card, without such a card the app cannot continue and will close when you tap the OK button.  Thank you.", "SD Card Not Found")
					Return ""
					'Activity.Finish
				End If
			End If
		End If
	End If
	'Now that the tests are finished, if a valid test path was found we can get the root.
	'If TestDir2 is not empty and it is different from TestDir1 then the external SD card must have a different path or name than that returned with
	'DirRootExternal.  Therefore, find the root of that path.  However, if TestDir2 is empty or is the same as TestDir1 then the path returned by
	'DirRootExternal IS the path to the root of the external SD card.
	
	'TestDir1 currently holds the root directory returned by DirRootExternal whereas TestDir2 holds the valid test directory consisting of the root and the subdirectory "/Android."  To make TestDir1 and TestDir2 equivalent for the conditional test below, we need to append the subdirectory "/Andrioid" to the contents TestDir1.  If we don't then TestDir1 and TestDir2 will always be different, even if their root is the same.  Therefore, first we will copy TestDir1 to T1 and append "/Android" to T1.  Thatway, TestDir1 will be unchanged.  Then we will compare T1 and TestDir2 to see whether or not they are the same.
	T1 = TestDir1
	T1 = T1 & "/Android"
	'Log("T1 = " & T1)
	'Log("TestDir2 = " & TestDir2)
	If (TestDir2.Length > 0) And (TestDir2 <> T1) Then
		StartDir = TestDir2 'Use the StartDir to process the string.
		'Log("StartDir = " & StartDir)
		'Log(" ")
		TempRoot = ""
		For I = 0 To StartDir.Length - 1
			'Get each char of StartDir.
			'Is current char a "/"?
			If StartDir.CharAt(I) = "/" Then
				'If it is, then add 1 to ShashCnt
				SlashCnt = SlashCnt + 1
				'Determine if the number of slashes is 3
				If SlashCnt = 3 Then
					'If it is then exit the loop - the root has been captured.
					Exit
				End If
			End If
			'Append the current char of the string to TempRoot
			SB.Append(StartDir.CharAt(I))
			'Log(" I = " & I & "; Current char = " & StartDir.CharAt(I) & "; SB = " & SB)
		Next
		TempRoot = SB.ToString
		'Log(" ")
		'Log("TempRoot = " & TempRoot)
	Else
		'TestDir1 (the path returned by DirRootExternal) IS the root we want.
		TempRoot = TestDir1
		'Log("TempRoot = TestDir1 and is:  " & TempRoot)
	End If
	'Log(" ")
	Return TempRoot
End Sub

حالا موقع استفاده اینجوری بنویسید :

Dim path As String=GetExtRoot
	If path="" Then 
		Try
			path=File.DirRootExternal
		Catch
			path=File.DirInternal
		End Try
	End If
لینک ارسال
به اشتراک گذاری در سایت های دیگر

بایگانی شده

این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.

  • کاربران آنلاین در این صفحه   0 کاربر

    • هیچ کاربر عضوی،در حال مشاهده این صفحه نیست.
×
×
  • اضافه کردن...